Skip to content

Instantly share code, notes, and snippets.

@dorianmariecom
Last active February 21, 2021 20:55
Show Gist options
  • Save dorianmariecom/fb9b3df58188cc5d520e256066d4fa17 to your computer and use it in GitHub Desktop.
Save dorianmariecom/fb9b3df58188cc5d520e256066d4fa17 to your computer and use it in GitHub Desktop.
// ==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