Skip to content

Instantly share code, notes, and snippets.

@juanique
Last active April 25, 2018 17:26
Show Gist options
  • Select an option

  • Save juanique/5f9b71a2c20117e1358d50b464c88d67 to your computer and use it in GitHub Desktop.

Select an option

Save juanique/5f9b71a2c20117e1358d50b464c88d67 to your computer and use it in GitHub Desktop.
Most played heroes in recent games
var heroesCount = {};
var rows = document.querySelector('.rgMasterTable ').children[2].children;
for (let i = 0; i < rows.length; i++) {
row = rows[i];
let heroName = row.children[4].innerText;
heroesCount[heroName] = heroesCount[heroName] || 0;
heroesCount[heroName] += 1;
}
var heroesArray = []
for (hero in heroesCount) {
heroesArray.push({"name": hero, "count": heroesCount[hero]});
}
heroesArray.sort((x, y) => {return y.count - x.count});
heroesArray.forEach(h => {
console.log(h.name + "\t" + h.count) ;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment