Last active
January 14, 2023 03:56
-
-
Save vaporwavie/353971ae37bb58425ed369e23cf48aec to your computer and use it in GitHub Desktop.
csgostats.gg scraping that lists your matches based on specific filters.
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
function getRowText(t,e){return t.querySelector(e).innerText.trim()}let csgo=document.querySelectorAll("#match-list-outer > table > tbody > tr"),csgoMatches=[...csgo].map(t=>({date:getRowText(t,"td:nth-of-type(1)"),map:getRowText(t,"td:nth-of-type(3)"),score:getRowText(t,"td:nth-of-type(4)"),kills:+getRowText(t,"td.col-stats:nth-of-type(7)"),deaths:+getRowText(t,"td.col-stats:nth-of-type(8)"),diff:+getRowText(t,"td.col-stats:nth-of-type(10)"),rating:+getRowText(t,"td:nth-last-child(2)")}));function filterMatches(t="date"){const e=Object.keys(csgoMatches[0]);if(!e.some(e=>e===t))throw Error(`Invalid filter. Try using: ${e.join(", ")}. You could also just run it without a filter.`);return csgoMatches.sort((e,o)=>o[t]-e[t])} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unminified version: