Skip to content

Instantly share code, notes, and snippets.

@TGOlson
Last active September 10, 2020 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TGOlson/b45efcbda6a7310b40531499629da93c to your computer and use it in GitHub Desktop.
Save TGOlson/b45efcbda6a7310b40531499629da93c to your computer and use it in GitHub Desktop.
(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