Last active
June 15, 2020 17:12
-
-
Save shikharbhardwaj/2f46b879181dfe31d1901f353331f0ed 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
var matchData = { | |
"team": [ | |
{ | |
"id": "", | |
"kills": "", | |
"assists": "", | |
"deaths": "", | |
"mvps": "", | |
"hs": "", | |
"score": "" | |
} | |
], | |
"opponent": [ | |
{ | |
"id": "", | |
"kills": "", | |
"assists": "", | |
"deaths": "", | |
"mvps": "", | |
"hs": "", | |
"score": "" | |
} | |
], | |
"rounds_won": 3, | |
"rounds_lost": 16 | |
} | |
// We don't know which row would be ours. | |
function getTeamPlayerRows(matchRow) { | |
var childElems = [... matchRow.children[1].children[0].children[0].children]; | |
return childElems.slice(1, 6); | |
} | |
function getOpponentPlayerRows(matchRow) { | |
var childElems = [... matchRow.children[1].children[0].children[0].children]; | |
return childElems.slice(7, 12); | |
} | |
function getPlayerData(playerRow) { | |
var mvps = parseInt(playerRow.children[5].innerText.slice(1)); | |
mvps = isNaN(mvps) ? 1 : mvps; | |
return { | |
"id": playerRow.getAttribute("data-steamid64"), | |
"kills": parseInt(playerRow.children[2].innerText), | |
"assists": parseInt(playerRow.children[3].innerText), | |
"deaths": parseInt(playerRow.children[4].innerText), | |
"mvps": mvps, | |
"hs": parseInt(playerRow.children[6].innerText.slice(0, -1)), | |
"score": parseInt(playerRow.children[7].innerText) | |
} | |
} | |
var scoreRow = firstRow.children[1].children[0].children[0].children[6]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment