dperelman / Slashdot Ad-Shield fix

// ==UserScript==
// @name     Slashdot Ad-Shield fix
// @version  1.0
// @author   Daniel Perelman (perelman@aweirdimagination.net)
// @license  MIT
// @icon     https://www.google.com/s2/favicons?sz=64&domain=slashdot.org
// @match    https://*.slashdot.org/*
// @match    https://slashdot.org/*
// @grant    none
// @run-at   document-start
// ==/UserScript==


(function() {
  'use strict';
  
  const w = window.wrappedJSObject || window;
  
  if (window.wrappedJSObject) {
    w.eval("window.originalAlert = window.alert")
    w.eval("document.originalQuerySelectorAll = document.querySelectorAll")

    w.eval(`window.alert = ${() => {
      throw Error("Used alert().");
    }}`);
    w.eval(`document.querySelectorAll = ${(arg) => {
      if (arg === "link,style") return document.originalQuerySelectorAll("invalid");
      return document.originalQuerySelectorAll(arg);
    }}`);
  } else {
    w.alert("Script only works on GreaseMonkey for Firefox.");
  }
})();