Skip to content

Instantly share code, notes, and snippets.

@shawwn
Last active June 9, 2021 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shawwn/3c1b71d69482afde15efb163925f2c7a to your computer and use it in GitHub Desktop.
Save shawwn/3c1b71d69482afde15efb163925f2c7a to your computer and use it in GitHub Desktop.
Show descendant count on Hacker News 'more' links
// ==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