Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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)
@hamoid
Copy link
Author

hamoid commented Jul 12, 2021

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.

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment