Skip to content

Instantly share code, notes, and snippets.

@hamoid
Created July 12, 2021 09:05
Show Gist options
  • Save hamoid/c5cc35f9cdcfc2d973caff08d9facfb9 to your computer and use it in GitHub Desktop.
Save hamoid/c5cc35f9cdcfc2d973caff08d9facfb9 to your computer and use it in GitHub Desktop.
// 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.

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