drudgereport-highlighter

Highlights links on Drudge Report based on tabloid/conservative/questionable bias.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name drudgereport-highlighter
// @description Highlights links on Drudge Report based on tabloid/conservative/questionable bias.
// @version 1
// @grant none
// @run-at document-idle
// @include https://drudgereport.com/
// @namespace https://network47.org/
// @license MIT
// ==/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 {
    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");