Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Filter HN rows by domain
// ==UserScript==
// @name Url Filterer
// @namespace Violentmonkey Scripts
// @match https://news.ycombinator.com/*
// @grant none
// @version 1.0
// @author -
// @description 6/30/2021, 5:27:00 PM
// ==/UserScript==
const BANNED = [
"medium.com",
"bariweiss.substack.com",
"yoyodyne.example.net",
"klein"
]
function isBanned(link) {
for (let ban of BANNED) {
if (link.textContent.includes(ban)) {
return true
}
}
}
function drop(link) {
const row = link.parentNode.parentNode.parentNode.parentNode;
row.nextElementSibling.remove();
row.nextElementSibling.remove();
row.remove();
}
[...document.querySelectorAll("span.sitestr")]
.filter(isBanned)
.forEach(drop)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment