Created
March 23, 2023 13:00
-
-
Save surprisetalk/462789361723211fcda71e13fa08bbc0 to your computer and use it in GitHub Desktop.
Userscript to hide any HackerNews story with "GPT" in its title.
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 HackerNews GPT-Free Feed | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Hides any Hacker News story with "GPT" in its title. | |
// @author Taylor Troesh | |
// @include https://news.ycombinator.com/* | |
// @grant none | |
// ==/UserScript== | |
[...document.getElementsByClassName("athing")].forEach(function(x) { | |
if(x.getElementsByClassName("titleline")[0].innerText.match(/gpt/i)) { | |
x.hidden = true; | |
x.nextElementSibling.hidden = true; | |
x.nextElementSibling.nextElementSibling = true; | |
} | |
}); |
Might need to add "Bard" to that match as well. :-/
and https://you.com
the hype is too strong :/
slightly shorter, using querySelectorAll
and querySelector
document.querySelectorAll('.athing').forEach(el => {
if (el.querySelector('.titleline').innerText.match(/gpt/i)) {
el.hidden = true;
el.nextElementSibling.hidden = true;
el.nextElementSibling.nextElementSibling = true;
}
});
also, is the last one supposed to have hidden
too? so maybe
document.querySelectorAll('.athing').forEach(el => {
if (el.querySelector('.titleline').innerText.match(/gpt/i)) {
el.hidden = true;
el.nextElementSibling.hidden = true;
el.nextElementSibling.nextElementSibling.hidden = true;
}
});
equivalent uBlock filter:
news.ycombinator.com##.athing:has(.titleline:has-text(/GPT/i))
news.ycombinator.com##.athing:has(.titleline:has-text(/GPT/i)) + tr
news.ycombinator.com##.athing:has(.titleline:has-text(/GPT/i)) + tr + tr
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can update the regex to match any number of terms:
/(gpt|bard)/i