SC2Casts.com Adblock Nag Screen Remover

Removes the 'disable Adblock' nag screen.

目前为 2016-06-01 提交的版本,查看 最新版本

// ==UserScript==
// @name         SC2Casts.com Adblock Nag Screen Remover
// @namespace    http://lazy.artifact
// @version      0.32
// @description  Removes the 'disable Adblock' nag screen.
// @author       Lazy Artifact
// @match        http://sc2casts.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
   

    var popupFuncBodyRegex = /display\s*=\s*["']/im,
        i,
        noop = function() {
            /* try to get some relaxation time in there. you don't *need* to update every day, do you? :) */
        },
        regexBodyAction = function(i, obj) {
            if (popupFuncBodyRegex.test(obj[i].toString())) {
                obj[i] = noop;
            }
        },
        walk = function(obj, action, maxDepth) {
            var i,
                nodes = [
                    {
                        value: obj,
                        parent: null
                    }
                ],
                nodeType,
                parent,
                currentDepth;

            while(nodes.length > 0) {
            
                obj = nodes.shift();
        
                parent = obj.parent;
                
                currentDepth = 0;

                while(parent !== null && parent !== undefined) {
                    parent = parent.parent;

                    currentDepth++;
                }
    
                if(maxDepth !== undefined && maxDepth !== null && currentDepth >= maxDepth) {
                    break;
                }

                for(i in obj.value) {
                  
                    if(obj.value[i] === null || obj.value[i] === undefined) {
                        continue;
                    }

                    if(!Object.prototype.hasOwnProperty.call(obj.value, i)) {
                        continue;
                    }
                                  

                    nodeType = typeof obj.value[i];
                   
                    if(nodeType === 'object' && !(obj.value[i] instanceof window.constructor)) {
                     
                        
                        if(nodes.findIndex(function(e) { return obj.value[i] === e; }) < 0) {
                            continue;
                        }

                        nodes.push({
                            value: obj.value[i],
                            parent: obj
                        });

                        continue;
                    }

                    if(nodeType !== 'function') {
                        continue;
                    }

                    action(i, obj.value);
                
                }

            }
        };
       
   
    
    walk(window, regexBodyAction, null);

   
})();