Filter Out Rotten Tomatoes

Removes links, images, and text which refer to Rotten Tomatoes or its rottentomatoes.com website, on any website.

目前為 2018-09-02 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Filter Out Rotten Tomatoes
// @namespace    http://tampermonkey.net/
// @version      1.0.1
// @description  Removes links, images, and text which refer to Rotten Tomatoes or its rottentomatoes.com website, on any website.
// @author       jcunews
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
  var
    rxText   = /rotten\b?tomatoes|(?:https?:\/\/)?(?:[a-z][a-z0-9-]*?\.)?rottentomatoes\.com[^,. ]+/gi,
    rxDomain = /(?:[a-z][a-z0-9-]*?\.)?rottentomatoes\.com/i;

  function processElement(node, url, nextNode) {
    if (rxDomain.test(node.href) || rxDomain.test(node.src) || rxText.test(getComputedStyle(node).backgroundImage)) {
      node.remove();
    } else {
      for (node = node.childNodes[0]; node; node = nextNode) {
        nextNode = node.nextSibling;
        processNode(node);
      }
    }
  }

  function processNode(node) {
    switch (node.nodeType) {
      case Node.ELEMENT_NODE:
        processElement(node);
        break;
      case Node.TEXT_NODE:
        if (rxText.test(node.nodeValue)) node.nodeValue = node.nodeValue.replace(rxText, "");
        break;
    }
  }

  processNode(document.body);

  (new MutationObserver(function(records) {
    records.forEach(function(record) {
      if (record.type === "characterData") {
        if (rxText.test(record.target.nodeValue)) record.target.nodeValue = record.target.nodeValue.replace(rxText, "");
      } else record.addedNodes.forEach(processNode);
    });
  })).observe(document.body, {childList: true, characterData: true, subtree: true});
})();