One of my secret shames is that I regularly check Drudge Report for breaking news (especially now that Twitter is compromised).
Drudge is a scumbag. But he’s a useful scumbag. He seemingly posts 24/7 (with some help, no doubt) every little bit of breaking news.
His preferences lean right, but at the end of the day he leans wherever the clicks are — so he’s not exactly what I would describe as a die hard conservative, if the story is big enough.
That means he links to tabloid sites, like The Sun, and others.
Very low-quality garbage, along side regular mainstream news sources. It sucks.
So, last night I got the idea to write a Greasemonkey script to iterate all the links on the page and style them appropriately if they’re from a blocklist. That’ll help me judge, at a glance, the likelihood that King Charles was actually seen shapeshifting into a lizard or not, and I can skip it.
And here it is, in it’s imperfect glory:
// ==UserScript==
// @name drudgereport-highlighter
// @version 1
// @grant none
// @run-at document-idle
// @include https://drudgereport.com/
// ==/UserScript==
el_links = document.getElementsByTagName("a");
const tabloidDomains = [
"mirror.co.uk",
"thesun.co.uk",
"the-sun.com",
"dailymail.co.uk",
"dailycaller.com",
"radaronline.com",
"bild.com"
];
const conservativeShitholeDomains = [
"washingtontimes.com",
"foxnews.com",
"infowars.com",
"breitbart.com",
"newsmax.com",
"freebeacon.com",
"realclearpolitics.com"
]
const secondClassDomains = [
"dnyuz.com",
"nypost.com",
"newzit.com",
]
function basename(url) {
try {
let back_offset = 0;
if (url.includes("co.uk")) back_offset = 1;
let foo = url.split("/")[2].split(".");
return `${foo[foo.length - 2 - back_offset]}.${
foo[foo.length - 1 - back_offset]
}`;
} catch {
// lazy hack
return "";
}
}
for (el of el_links) {
domain = basename(el.href);
let updated = false;
if (tabloidDomains.filter((d) => d.includes(domain)).length) {
el.style.backgroundColor = "darkred";
el.style.color = "white";
el.title = "Tabloid";
updated = true;
}
else if (conservativeShitholeDomains.filter((d) => d.includes(domain)).length) {
el.style.backgroundColor = "#FF0000AA";
el.style.color = "white";
el.title = "Conservative Shithole";
updated = true;
}
else if (secondClassDomains.filter((d) => d.includes(domain)).length) {
el.style.backgroundColor = "darkcyan";
el.style.color = "white";
el.title = "Second-class Domain";
updated = true;
}
if (updated) {
el.style.borderRadius = "4px"
el.style.padding = "0 0.25em"
el.title = `${el.title} [${domain}]`
let tag = document.createElement('span')
tag.innerHTML = domain
tag.style.fontFamily = "sans-serif";
tag.style.fontSize = "8pt";
tag.style.color = "black"
tag.style.backgroundColor= "white"
tag.style.padding = "0 0.25em"
el.style.paddingBottom = "0.20em"
tag.style.marginLeft = "0.25em"
tag.style.borderRadius="10px"
el.style.textDecoration = "none";
el.append(tag)
}
}
console.log("drudgereport-highlighter installed");