The Epoch Times - Ads & Paywall Removal

Removes ads and paywall on The Epoch Times.

当前为 2021-08-08 提交的版本,查看 最新版本

// ==UserScript==
// @name            The Epoch Times - Ads & Paywall Removal
// @namespace       The Epoch Times - Ads & Paywall Removal
// @version         0.1
// @description     Removes ads and paywall on The Epoch Times.
// @author          asheroto
// @license         MIT
// @match           https://www.theepochtimes.com/*
// @icon            https://www.theepochtimes.com/favicon.ico
// @grant           GM_addElement
// @grant           GM_log
// ==/UserScript==

// ==OpenUserScript==
// @author          asheroto
// ==/OpenUserScript==

/* jshint esversion: 6 */

(function () {
  // Remove via CSS
  let css = `
        #landing-page { display: none; }
        .home-wall { display: none; }
        #main { overflow: unset !important; height: unset !important; }
        #main > div { border-top: unset; margin-top: 0px; }
        .right_col.noprint > div { margin: unset !important; }
        .top_ad { display: none; }
        #ad_right_top_300x250_1 { display: none; }
        .login_wrapper { display: none; }
        #partnership { display: none; }
        #footer { display: block !important; }
    `;
  let head = document.head || document.getElementsByTagName("head")[0],
    style = document.createElement("style");
  head.appendChild(style);
  style.appendChild(document.createTextNode(css));

  // Run tag removal
  const blacklist = ["doubleclick.", "amazon-adsystem", "adnxs", "ads."];
  const tags = ["script", "iframe"];
  let repeat = setInterval(function () {
    tags.forEach(function (item) {
      document.getElementsByTagName(item).forEach(function (src) {
        blacklist.forEach(function (b) {
          if (src.src.includes(b)) {
            src.style.display = "none";
            console.log(src.src);
          }
        });
      });
    });
  }, 500);

  // Clear tag removal after 5 seconds
  setTimeout(function () {
    clearInterval(repeat);
  }, 5000);
})();