Created
July 12, 2021 09:05
-
-
Save hamoid/c5cc35f9cdcfc2d973caff08d9facfb9 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
// Run in the js console while viewing a submission in HackerNews | |
// for example while visiting https://news.ycombinator.com/item?id=27799859 | |
console.log('Users with more than 1 answer:') | |
var counts = {}; | |
var arr = Object.values(document.getElementsByClassName('hnuser')).map(h => h.innerHTML); | |
arr.forEach(function (x) { | |
counts[x] = (counts[x] || 0) + 1; | |
}); | |
var sorted = Object.entries(counts); | |
var result = ''; | |
sorted.sort((a,b) => b[1]-a[1]) | |
sorted.forEach(i => { | |
if(i[1] > 1) { | |
result += '■'.repeat(i[1]) + ` ${i[0]} (${i[1]})\n` | |
} | |
}) | |
console.log(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works on single-page posts in hn but not in multi-page ones. That would require searching for the "more" link, downloading following pages, accumulating totals.