MonkeyType AutoTyper Bot

A Bot that automatically types for you in MonkeyType.

  1. // ==UserScript==
  2. // @name MonkeyType AutoTyper Bot
  3. // @author ByfronFucker
  4. // @description A Bot that automatically types for you in MonkeyType.
  5. // @icon https://th.bing.com/th/id/R.c8397fb766c4397fea8a8b499c15a453?rik=aROX42RoH7HhXw&pid=ImgRaw&r=0
  6. // @version 1.0
  7. // @match *://monkeytype.com/*
  8. // @run-at document-start
  9. // @grant none
  10. // @license MIT
  11. // @namespace https://greasyfork.org/en/users/1380005-real-aquzr
  12. // ==/UserScript==
  13.  
  14. /* jshint esversion:6 */
  15. (function () {
  16. "use strict";
  17.  
  18. const log = console.log;
  19.  
  20. let isTyping = false;
  21.  
  22. function canType() {
  23. const typingTest = document.getElementById("typingTest");
  24. const isHidden = typingTest.classList.contains("hidden");
  25. return !isHidden;
  26. }
  27.  
  28. function getNextCharacter() {
  29. const currentWord = document.querySelector(".word.active");
  30. for (const letter of currentWord.children) {
  31. if (letter.className === "") return letter.textContent;
  32. }
  33. return " ";
  34. }
  35.  
  36. function pressKey(key) {
  37. const wordsInput = document.getElementById("wordsInput");
  38. wordsInput.value += key;
  39.  
  40. const KeyboardEvent = new KeyboardEvent("keyup", { key: key });
  41. const InputEvent = new InputEvent("input", { data: key });
  42.  
  43. wordsInput.dispatchEvent(InputEvent);
  44. wordsInput.dispatchEvent(KeyboardEvent);
  45. }
  46.  
  47. function typeCharacter() {
  48. if (!canType() || !isTyping) {
  49. return;
  50. }
  51.  
  52. const nextChar = getNextCharacter();
  53. pressKey(nextChar);
  54.  
  55. // Automatically type next character immediately
  56. setTimeout(typeCharacter, 0);
  57. }
  58.  
  59. const gui = document.createElement("div");
  60. gui.style.position = "fixed";
  61. gui.style.bottom = "30%";
  62. gui.style.right = "0";
  63. gui.style.transform = "translateY(50%)";
  64. gui.style.padding = "5px";
  65. gui.style.background = "rgba(0, 0, 0, 0.6)";
  66. gui.style.color = "white";
  67. gui.style.fontFamily = "sans-serif";
  68. gui.style.fontSize = "12px";
  69. gui.style.zIndex = "9999";
  70. gui.innerHTML = `
  71. <div style="display: flex; flex-direction: column;">
  72. <button id="startButton" style="background: green; color: white;">Start Typing</button>
  73. <button id="stopButton" style="background: red; color: white; display: none;">Stop Typing</button>
  74. </div>
  75. `;
  76. document.body.appendChild(gui);
  77.  
  78. const startButton = document.getElementById("startButton");
  79. const stopButton = document.getElementById("stopButton");
  80.  
  81. startButton.addEventListener("click", function () {
  82. if (canType()) {
  83. isTyping = true;
  84. log("STARTED TYPING");
  85. startButton.style.display = "none";
  86. stopButton.style.display = "block";
  87. typeCharacter();
  88. }
  89. });
  90.  
  91. stopButton.addEventListener("click", function () {
  92. isTyping = false;
  93. log("STOPPED TYPING");
  94. startButton.style.display = "block";
  95. stopButton.style.display = "none";
  96. });
  97.  
  98. })();