Last active
February 21, 2021 20:55
-
-
Save dorianmariecom/fb9b3df58188cc5d520e256066d4fa17 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
// ==UserScript== | |
// @name De-Culture-War Hacker News | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Hides any Hacker News story with more comments than points. | |
// @author Nate Berkopec | |
// @include https://news.ycombinator.com/* | |
// @grant none | |
// ==/UserScript== | |
var stories = [...document.getElementsByClassName("athing")] | |
stories.forEach(function(el) { | |
let sibling = el.nextElementSibling | |
let spacer = sibling.nextElementSibling | |
let scoreEl = sibling.getElementsByClassName("score"); | |
if (scoreEl.length === 0) { | |
return; | |
} | |
let score = sibling.getElementsByClassName("score")[0].innerText.match(/\d+/)[0] | |
let comments = sibling.getElementsByClassName("subtext")[0].lastElementChild.innerText.match(/\d+/) | |
if(comments && parseInt(comments[0], 10) > parseInt(score, 10)) { | |
el.hidden = true | |
sibling.hidden = true | |
spacer.hidden = true | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment