-
-
Save Fortyseven/4efd8fc1385c63cf14c47f8545bf0742 to your computer and use it in GitHub Desktop.
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 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"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment