Last active
June 9, 2021 00:14
Show descendant count on Hacker News 'more' links
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
// ==UserScript== | |
// @name More Hacker News | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Show descendant count on Hacker News 'more' links | |
// @author Shawn Presser aka sillysaurusx (https://twitter.com/theshawwn) | |
// @match https://news.ycombinator.com/* | |
// @icon https://www.google.com/s2/favicons?domain=ycombinator.com | |
// @grant none | |
// ==/UserScript== | |
/* | |
How it looks: https://i.imgur.com/AYV8O9T.png | |
(Notice each 'more' link shows how many replies you'll see if you follow it.) | |
Installation instructions: | |
- Install tampermonkey: https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo?hl=en | |
- Go to hacker news | |
- Click the tampermonkey icon (upper right) | |
- Create new script | |
- Replace it with this entire gist | |
- Press Command-S to save. (Control-S, whatever. Make sure you actually save, otherwise it won't work.) | |
- You should now see how many comments are waiting for you at each 'more' link | |
*/ | |
(function() { | |
'use strict'; | |
[...byTag(document.body, 'a')].filter(x => x.innerText == 'more').map(x => { x.innerText = `${byClass($(x.href.split('item?id=')[1]), 'togg')[0].attributes['n'].value - 1} more`; }); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment