Skip to content

Instantly share code, notes, and snippets.

@rektide
Created June 30, 2021 21:41
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 rektide/6d0af312d03482a7f3593f8fee7ef188 to your computer and use it in GitHub Desktop.
Save rektide/6d0af312d03482a7f3593f8fee7ef188 to your computer and use it in GitHub Desktop.
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