Reason AnyClip Die

Removes annoying AnyClip Video on Reason.com.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Reason AnyClip Die
// @namespace    ReasonAnyClipDie
// @version      0.1
// @description  Removes annoying AnyClip Video on Reason.com.
// @author       shellster
// @match        https://reason.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var MutationObserver = window.MutationObserver;
    var myObserver = new MutationObserver (mutationHandler);
    var obsConfig = {
        childList: true, attributes: true,
        subtree: true, attributeFilter: ['class']
    };

    myObserver.observe (document, obsConfig);

    function mutationHandler (mutationRecords) {
        mutationRecords.forEach ( function (mutation) {

            if (mutation.type == "childList"
                && typeof mutation.addedNodes == "object"
                && mutation.addedNodes.length
               )
            {
                for (var J = 0, L = mutation.addedNodes.length; J < L; ++J) {
                    checkForAD(mutation.addedNodes[J]);
                }
            }
            else if (mutation.type == "attributes") {
                checkForAD(mutation.target);
            }
        } );
    }

    function checkForAD(node) {
        //-- Only process element nodes
        if (node.nodeType === 1) {
            if(node.className .toLowerCase().indexOf('anyclip-') != -1)
            {
                try
                {
                    node.parentNode.removeChild(node);
                }
                catch(ex){}
            }
        }
    }

    function walkTheDOM(node, func) {
        func(node);
        node = node.firstChild;
        while (node) {
            walkTheDOM(node, func);
            node = node.nextSibling;
        }
    }

    walkTheDOM(document.body, checkForAD);
})();