Created
February 14, 2023 17:57
-
-
Save iamabhi747/41a24f1ea21ceb07426c1afe2df3093e to your computer and use it in GitHub Desktop.
TypeRacer automation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
automates typing in TypeRacer (typeracer.com) | |
it will try to get secified wpm, but wpm in TypeRacer is complex so its not perfect | |
use: | |
-> run `await raceit(wpm)` when race about to start (countdown is ongoing) | |
*/ | |
async function raceit(wpm) { | |
div = document.getElementsByClassName("inputPanel")[0].children[0].children[0].children[0].children[0].children[0].children[0].children[0].children[0].children[0] | |
input = document.getElementsByClassName("txtInput")[0] | |
text = "" | |
for (let i = 0; i < div.children.length; i++) { | |
text += div.children[i].innerHTML | |
} | |
chrs_count = text.length | |
words = text.split(" ") | |
words_count = words.filter((v)=>{return v.length > 1;}).length | |
words_count += Math.floor((words.length - words_count)/4) | |
time = ((words_count / wpm)*60*1000) / chrs_count | |
while (input.disabled) { await new Promise(resolve => setTimeout(resolve, 50)); } | |
console.log("Started") | |
for (let i =0; i < text.length; i++) { | |
input.value += text[i]; | |
input.dispatchEvent(new Event('mousedown')); | |
await new Promise(resolve => setTimeout(resolve, time)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment