Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
TypeRacer cheat
let join_race_links = [];
check_for(['.mainMenu', '.inputPanel'], 2000, () => {
const menu = document.querySelector('.mainMenu');
if(menu !== null) {
const main_menu_items = menu.querySelectorAll('.mainMenuItemText');
const multiplayer_link = main_menu_items[0].querySelector('.gwt-Anchor');
const singleplayer_link = main_menu_items[1].querySelector('.gwt-Anchor');
join_race_links = [multiplayer_link, singleplayer_link];
} else {
join_race_links[0] = document.querySelector('.raceAgainLink') || document.querySelector('.raceAgainLink raceAgainLink-flashOn');
}
for(let link of join_race_links) {
link.addEventListener('click', type);
}
});
function type() {
check_for(['.inputPanel'], 1000, () => {
const inputPanel = document.querySelector('.inputPanel');
const table = inputPanel.childNodes[0];
const table_elements = table.childNodes;
const text_display = table_elements[0];
const text = text_display.innerText;
const input_area = document.querySelector('.txtInput');
let iterator = 0;
function _type() {
input_area.value += text[iterator];
if(input_area.value.length - 1 === iterator) {
iterator++;
}
if(iterator === text.length - 1) {
document.removeEventListener('keypress', _type);
}
}
document.addEventListener('keypress', _type);
});
}
function check_for(elements, interval, callback) {
setTimeout(() => {
const found = (() => {
for(let element of elements) {
const elt = document.querySelector(element);
if(elt !== null) {
return true;
}
}
return false;
})();
if(!found) {
check_for(elements, interval, callback);
} else {
callback();
}
}, interval);
}
{
"manifest_version": 2,
"name": "Typeracer cheat",
"version": "1.0",
"content_scripts": [
{
"run_at": "document_end",
"matches": [
"https://play.typeracer.com/*"
],
"js": [
"./index.js"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment