Skip to content

Instantly share code, notes, and snippets.

@hhenrichsen
Last active October 30, 2019 01:22
Show Gist options
  • Save hhenrichsen/927d3cd0dad60aa67975c171df9a0e13 to your computer and use it in GitHub Desktop.
Save hhenrichsen/927d3cd0dad60aa67975c171df9a0e13 to your computer and use it in GitHub Desktop.
var findScores = function() {
return Array.from(document.querySelectorAll('span[class^=StudentPointsLabel]'))
.map(i => i.textContent)
.filter(i => i !== "" && i !== "1/1" && i !== "0/1")
.map(i => i.split('/').map(i => parseFloat(i)))
.reduce((a, i) => {a[0] += i[0]; a[1] += i[1]; return a}, [0, 0]);
}
var alertScores = function() {
let scores = findScores();
alert(`Your score is ${scores[0]} / ${scores[1]} (${scores[0] / scores[1] * 100}%)`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment