🤔 How to cheat on any online typing test

Fowled
3 min readJun 16, 2021

--

If you have ever heard of “words per minute” (WPM), you have probably already tested your typing speed. You’ve also compared it to other people around the world in a competition, where the one who types the fastest 100 of the most common words in a language within a given time wins.

Example of a typing test website

Well, chances are you’ve already met a person exceeding 300 words per minute, and most likely cheating. The most effective way to counter that is maybe… to cheat too.

⚠ Disclaimer: I don’t encourage cheating, as it ruins the player experience. However, there are non-multiplayer modes that have no negative consequences on other people.

With that out of the way, let’s begin by analyzing how these sites work. For most of them, an algorithm highlights a word from a generated text so that you type it in an input as fast as possible, as shown below.

“10fastfingers” typing test, with an highlighted word (“last”)

For the sake of this article, I’ll take the 10fastfingers.com website as an example. To execute the code we’ll produce, download a userscript manager such as Tampermonkey, click on the add-on logo and “Create a new script”.

Right here 😉

Great! Everything is setup. The first thing we should do is to create a function, which will be waiting for the highlighted word to show up. This can be easily done with a setInterval() method.

function awaitElement() {
let interval = setInterval(function() {
if (document.getElementsByClassName("highlight")[0]) {
clearInterval(interval);
searchNewWord();
}
}, 100);
}

Here, we try to get the “highlight” element to see whether it exists on the document or not. Once it is found, the interval is cleared and another function is called.

Okay, we successfully managed to get the highlighted word, but apart from that, nothing happens. Now what?
Well, time to create our second function, named searchNewWord()

function searchNewWord() {
let interval = setInterval(function() {
let word = document.getElementsByClassName("highlight")[0].textContent;
document.getElementsByClassName("form-control")[0].value = word;
}, 100);
}

Another interval bytes the dust… haha…?
In all seriousness, after getting the highlighted word content, the algorithm will search for the input and overwrite its content, every 100ms (0.1s).
Take a look below.

I only have to enter “space” for the word to register

Here is the whole userscript file. You could also click here for the userscript to install automatically.

// ==UserScript==
// @name Typing race
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Try to type as fast as possible but with a bot help
// @author Mazz
// @match https://10fastfingers.com/*
// @icon https://www.google.com/s2/favicons?domain=10fastfingers.com
// @grant none
// ==/UserScript==
(function () {
'use strict';
awaitElement();function awaitElement() {
let interval = setInterval(function () {
if (document.getElementsByClassName("highlight")[0]) {
clearInterval(interval);
searchNewWord();
}
}, 100);
}
function searchNewWord() {
let interval = setInterval(function () {
let word = document.getElementsByClassName("highlight")[0].textContent;
document.getElementsByClassName("form-control")[0].value = word;
}, 100);
}
})();

Thanks for reading! If this story helped you, consider sharing it to your friends 🙂

--

--

Fowled
Fowled

No responses yet