console.log typeracer game code example

Example: typeracer hack

(() => {
	const typeDelay = 20;

	const txtInput = document.querySelector('.txtInput');
	const textElmParent = document.querySelector(
		'#gwt-uid-15 > table > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(1) > td > table > tbody > tr:nth-child(1) > td > div > div:nth-child(1)'
	);
	
	function typeChars(chars, callback) {
		if (chars.length > 0) {
			txtInput.value += chars[0];
			window.setTimeout(() => typeChars(chars.slice(1), callback), typeDelay);
		} else {
			window.setTimeout(callback, typeDelay);
		}
	}
	
	let text = '';
	for (let i = 1, textFragment; (textFragment = textElmParent.querySelector(`:nth-child(${i})`)) !== null; i++) {
		text += textFragment.innerText;
	}
	
	typeChars(text, () => console.log('Done!'));
})();