Created
March 23, 2023 06:03
-
-
Save namuan/c979b99080e571fe82f527d8b6a7adfe to your computer and use it in GitHub Desktop.
Revisions
-
namuan created this gist
Mar 23, 2023 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ // ==UserScript== // @name Hide Links From Mainstream Media // @namespace http://tampermonkey.net/ // @version 0.1 // @description Hides all links from mainstream media websites on news.ycombinator // @match https://news.ycombinator.com/* // @grant none // ==/UserScript== (function() { 'use strict'; // Specify the list of mainstream media website substrings to check for var mainstreamMediaWebsites = [ "cnn.com", "bbc.com", "nytimes.com", "washingtonpost.com", "theguardian.com", "abcnews.go.com", "nbcnews.com", "cbsnews.com", "foxnews.com", "msnbc.com", "npr.org", "reuters.com", "apnews.com", "aljazeera.com", "bloomberg.com", "forbes.com", "ft.com", "wsj.com", "arstechnica.com" ]; // Find all HTML elements containing links var linkElements = document.querySelectorAll("a[href^='from?site=']"); // Loop through all link elements and remove the closest <tr> element with class 'athing' to the link if the link is from a mainstream media website for (var i = 0; i < linkElements.length; i++) { var link = linkElements[i]; if (link.href) { if (mainstreamMediaWebsites.some(function(site) { return link.href.includes(site); })) { var tr = link.closest("tr.athing"); if (tr) { // Hide the <tr> element tr.style.display = "none"; } } } } })();