Skip to content

Instantly share code, notes, and snippets.

@jjason685
Created January 18, 2020 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjason685/79afc7b3cecd9f79703586962407914c to your computer and use it in GitHub Desktop.
Save jjason685/79afc7b3cecd9f79703586962407914c to your computer and use it in GitHub Desktop.
TypeRacer Hack
const puppeteer = require('puppeteer');
function delay(timeout) {
return new Promise((resolve) => {
setTimeout(resolve, timeout);
});
}
const play = async (page) => {
await page.waitForSelector('table tbody tr td div div span[unselectable]');
const data = await page.evaluate(() => {
const tds = Array.from(document.querySelectorAll('table tbody tr td div div span[unselectable]'))
return tds.map(span => span.textContent)
});
await page.waitForSelector('.txtInput')
const textField = await page.$('.txtInput');
let status = await page.$('.gameStatusLabel');
let text = await page.evaluate(status => status.textContent, status);
while (text !== 'The race is on! Type the text below:') {
status = await page.$('.gameStatusLabel');
text = await page.evaluate(status => status.textContent, status);
await delay(75);
}
for (let word of data) {
await textField.type(word, { delay: Math.floor(Math.random() * 9) + 9 });
}
await textField.dispose();
}
async function run() {
const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();
await page.setViewport({ width: 1200, height: 900 });
await page.goto('https://play.typeracer.com?rt=xeci0ulhy');
await page.waitForSelector('.raceAgainLink');
await page.click('.raceAgainLink');
await play(page);
}
run();
@alii
Copy link

alii commented Jan 18, 2020

(its a joke i love you jason)

Hi I'm Jason. I own a massive bot called Wrath which I spend 100% of my time on. The remaining ten percent of time is spent building a hack for Typeracer! Enjoy :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment