Created
July 1, 2020 19:14
-
-
Save leonsilicon/84a07f8f0322479105c07bc050720476 to your computer and use it in GitHub Desktop.
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
/* | |
Instructions: | |
Go onto typeracer.com and press the `My Scores` tab | |
Then go to https://code.jquery.com/jquery-3.5.1.slim.min.js and copy paste the code into the console | |
Then copy paste this code into the console | |
Wait a few minutes (depending on how many races you did) | |
At the end, it should output your race data. If not, type `statsString` into the console | |
*/ | |
var statsString = ''; | |
var statsTable = $('.StatsTable').eq(1).parent().parent(); | |
getStats(); | |
function clickOlder() { | |
$('.LinkButtonGroupLink:contains("older")')[0].click(); | |
} | |
function getStats() { | |
statsTable | |
.find('.headerRow') | |
.parent() | |
.children('tr:not(.headerRow)') | |
.each(function () { | |
const fields = $(this).children(); | |
const raceNumber = fields.eq(0).text(); | |
const wpm = fields.eq(1).text().split(' ')[0]; | |
const accuracy = fields.eq(2).text(); | |
const points = fields.eq(3).text(); | |
const date = fields.eq(4).text(); | |
statsString += `${raceNumber},${wpm},${date}\n`; // customize this string for what data you want to collect | |
}); | |
} | |
var observer = new MutationObserver(function (mutationList, observer) { | |
for (const mutation of mutationList) { | |
if (mutation.type === 'childList' && mutation.addedNodes.length > 0) { | |
getStats(); | |
} | |
} | |
}); | |
observer.observe(statsTable.get(0), { | |
attributes: true, | |
childList: true, | |
subtree: true | |
}); | |
var interval = setInterval(() => { | |
if ($('.LinkButtonGroupLink:contains("older")').length === 1) { | |
clickOlder(); | |
getStats(); | |
} else { | |
clearInterval(interval); | |
console.log(statsString); | |
} | |
}, 5000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment