faeller / 10ff Live WPM

// ==UserScript==
// @namespace    http://up.faeller.me/
// @name         10ff Live WPM
// @description  Toggleable live wpm counter for 10fastfingers.com
// @version      1.11
// @author       Laurin Fäller and Alfredo
// @match        https://10fastfingers.com/typing-test/*
// @copyright    2018, faeller (https://openuserjs.org//users/faeller)
// @license      Apache-2.0
// @grant        none
// ==/UserScript==
$(document).ready(function () {
  window.onload = function () {
    liveWpmHidden = false;
    liveWpm = 0;
  }

  function draw() {
    window.liveWpm = Math.round((error_keystrokes / 5) / ((60.01 - countdown) / 60));
    $('#preview').html("<button title=\"show/hide content\" class=\"btn btn-info\" type=\"button\" onclick=\"window.liveWpmHidden=!window.liveWpmHidden\"><b>Show/Hide</b></button>" +
      "<font size='+3' " + (window.liveWpmHidden ? "style=\"display:none\"" : "") + ">" +
      "<br><b>WPM:</b> " + ((window.liveWpm > 400 || window.liveWpm < 0) ? 0 : window.liveWpm) +
      "<br><b>Key Strokes:</b> " + error_keystrokes +
      "<br><b>Words:</b> " + error_correct +
      "</<font size='+3'>");
    $('#words').before("<div id='preview'></div>");
  };

  window.setInterval(function () {
    draw();
  }, 300);
});