Last active
September 10, 2020 17:26
-
-
Save TGOlson/b45efcbda6a7310b40531499629da93c 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
(function () { | |
const initialTeams = Array.prototype.slice.call(document.querySelectorAll('#schedsubnav li')); | |
const scores = []; | |
// gets results based on what is displayed, clicks to change selected team need to happen before this | |
const getResults = () => { | |
const res = document.querySelectorAll('table.Table.Table-interactive tbody tr'); | |
const arr = Array.prototype.slice.call(res); | |
return arr.map(row => { | |
const score = row.querySelector('td span.yfa-score').textContent; | |
return score.split(' - ')[0]; | |
}); | |
} | |
const run = (teams) => { | |
if (teams.length === 0 ) { | |
console.log('no more teams'); | |
console.log('results', scores); | |
const csv = scores.map(s => s.join(',')).join('\n') | |
console.log('csv', csv) | |
return; | |
} | |
const team = teams[0]; | |
const remainingTeams = teams.slice(1); | |
team.querySelector('a').click(); | |
window.setTimeout(() => { | |
const name = team.querySelector('a').textContent; | |
const results = getResults(); | |
scores.push([name, ...results]); | |
console.log('done w/ team', name); | |
run(remainingTeams); | |
}, 500) | |
} | |
run(initialTeams); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment