Created
June 30, 2021 21:41
-
-
Save rektide/6d0af312d03482a7f3593f8fee7ef188 to your computer and use it in GitHub Desktop.
Filter HN rows by domain
This file contains hidden or 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 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