Auto Typer for TypingClub

This script types for you automatically on www.typingclub.com:

  1. // ==UserScript==
  2. // @name Auto Typer for TypingClub
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description This script types for you automatically on www.typingclub.com:
  6. // 1. Open the website
  7. // 2. Blaze past the tutorials
  8. // 3. Go into a level
  9. // 4. Open Console
  10. // 5. Paste the script and press ENTER
  11. // @match https://www.typingclub.com/*
  12. // @grant none
  13. // @license MIT
  14. // ==/UserScript==
  15.  
  16. /**
  17. * NOTE: When delay (in ms between two strokes) is too low, the site might bug out and the result page will not be shown
  18. */
  19. const minDelay = 60;
  20. const maxDelay = 60;
  21.  
  22. const keyOverrides = {
  23. [String.fromCharCode(160)]: ' ' // convert hardspace to normal space
  24. };
  25.  
  26. function getTargetCharacters() {
  27. const els = Array.from(document.querySelectorAll('.token span.token_unit'));
  28. const chrs = els
  29. .map(el => {
  30. // get letter to type from each letter DOM element
  31. if (el.firstChild?.classList?.contains('_enter')) {
  32. // special case: ENTER
  33. return '\n';
  34. }
  35. let text = el.textContent[0];
  36. return text;
  37. })
  38. .map(c => keyOverrides.hasOwnProperty(c) ? keyOverrides[c] : c); // convert special characters
  39. return chrs;
  40. }
  41.  
  42. function recordKey(chr) {
  43. // send it straight to the internal API
  44. window.core.record_keydown_time(chr);
  45. }
  46.  
  47. function sleep(ms) {
  48. return new Promise(r => setTimeout(r, ms));
  49. }
  50.  
  51. async function autoPlay(finish) {
  52. const chrs = getTargetCharacters();
  53. for (let i = 0; i < chrs.length - (!finish); ++i) {
  54. const c = chrs[i];
  55. recordKey(c);
  56. //console.log(c, c.charCodeAt());
  57. await sleep(Math.random() * (maxDelay - minDelay) + minDelay);
  58. }
  59. }
  60.  
  61. // ############################################################################################################
  62. // go!
  63. // ############################################################################################################
  64.  
  65. autoPlay(true);