Anti-AdBlocker & DeBlocker

Remove Anti-AdBlocker & DeBlocker

目前為 2020-02-29 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Anti-AdBlocker & DeBlocker
// @version      1.07
// @description  Remove Anti-AdBlocker & DeBlocker
// @author       Elwyn
// @license      MIT
// @namespace    https://openuserjs.org/install/Elwyn/Anti-AdBlocker_DeBlocker.user.js
// @include      *
// @run-at document-start
// @grant unsafeWindow
// ==/UserScript==
(function() {

    // Skip iframes
    if ( window.location !== window.parent.location ) return;

    // Exclude domains
    var excludes = ['360.cn', 'adblockplus.org', 'agar.io', 'aliexpress.com', 'amazon.', 'apple.com', 'ask.com', 'baidu.com', 'bing.com', 'bufferapp.com', 'calm.com', 'chatango.com', 'chromeactions.com', 'dolldivine.com', 'easyinplay.net', 'ebay.com', 'exacttarget.com', 'facebook.com', 'flattr.com', 'flickr.com', 'fsf.org', 'greasyfork.org', 'ghacks.net', 'google.', 'imdb.com', 'imgbox.com', 'imgur.com', 'instagram.com', 'jsbin.com', 'jsfiddle.net', 'linkedin.com', 'live.com', 'mail.ru', 'microsoft.com', 'msn.com', 'openuserjs.org', 'pandoon.info', 'paypal.com', 'pinterest.com', 'plnkr.co', 'popmech.ru', 'preloaders.net', 'qq.com', 'reddit.com', 'stackoverflow.com', 'tampermonkey.net', 'twitter.com', 'vimeo.com', 'wikipedia.org', 'w3schools.com', 'xemvtv.net', 'yahoo.', 'yandex.ru', 'youtu.be', 'youtube.com', 'vod.pl'];
    if ( new RegExp( excludes.join('|').replace(/\./g,'\.') ).test( location.host ) ) return;

    // AdBlock Pattern to Search
    var adblock_pattern = 'Ad-?Block|bloqueur|bloqueador|Werbeblocker|آدبلوك بلس|блокировщиком';
    var disable_pattern = 'kapat|disabl|désactiv|desactiv|desativ|deaktiv|απενεργοποίηση|запрещать|állítsd le|publicités|рекламе|verhindert|advert|kapatınız';

    // HELPER Functions
    //-----------------
    function addStyle(str) {
        var node = document.createElement('style');
        node.innerHTML = str;
        document.body.appendChild(node);
    }

    function randomInt( min, max )
    {
        // min and max included
        if ( max === undefined ) {
            max = min;
            min = 0;
        }
        return Math.floor(min + Math.random() * (max - min + 1));
    }

    function getRandomName( size )
    {
        var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
        var i;
        var name = '';
        for (i = 0; i < (size||randomInt(10,24)); i++)
        {
            name += chars.charAt( randomInt(0,chars.length) );
        }
        return name;
    }

    // Get className or Make a random one
    function includeClass( el ) {
        var name = el.className;
        if ( typeof name != 'undefined' ) {
            if( /\s/.test( name ) ) {
                name = name.split(' ');
                name = name[0];
            }
        } else {
            name = getRandomName();
            el.classList.add( name );
        }
        return '.' + name + ',';
    }

    // Main Function
    function removeModal( el )
    {
        console.log( 'ANTI-ADBLOCKER: Found!');

        var classes = '';

        // Holder of the Modal message
        for (;;) {
            if ( el.parentNode.tagName == 'BODY' ) break;
            classes += includeClass( el );
            el = el.parentNode;
        }

        // Blackout Elements
        document.querySelectorAll( 'div' ).forEach( ( el ) => {
            let style = window.getComputedStyle( el );
            let height;
            if ( style.getPropertyValue( 'position' ) == 'fixed' )
            {
                height = style.getPropertyValue( 'height' );
                if ( height == '100%' )
                {
                    classes += includeClass( el );
                }
                else if ( /px/i.test( height ) && parseInt( height ) > window.innerHeight - 100 )
                {
                    classes += includeClass( el );
                }
            }
        });

        if ( classes.length > 0 ) {

            classes = classes.substring( 0, classes.length - 1 );

            //console.log( 'ANTI-ADBLOCKER - ClassNames:' + classes );

            // Blocks the possibility of being able to remove the BODY or the HEAD
            let $_removeChild = unsafeWindow.Node.prototype.removeChild;
            unsafeWindow.Node.prototype.removeChild = ( node ) => {
                if ( node.tagName != 'HEAD' && node.tagName != 'BODY' ) {
                    $_removeChild.apply( this, arguments );
                }
            }

            // Hide Anti-AdBlocker Elements
            addStyle( classes + '{ display: none !important; }' );

            // Remove Blur FX of Elements
            addStyle( '* { -webkit-filter: blur(0px) !important; filter: blur(0px) !important; }' );
        }

    }

    document.addEventListener('DOMContentLoaded', function() {
        // Mutation Observer
        var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;

        // Create an observer instance
        var observer = new MutationObserver( (mutations) => {
            mutations.forEach( (mutation) => {
                if ( mutation.addedNodes.length ) {
                    Array.prototype.forEach.call( mutation.addedNodes, (addedNode) => {
                        // skip nodes with undefined text
                        if ( typeof addedNode.innerText == 'undefined' ) return;
                        // skip nodes without text
                        if ( addedNode.innerText.length < 1 ) return;
                        // search texts that ask to deactivate the AdBlock
                        if( new RegExp( adblock_pattern.replace(/(\w)/g, '$1\s*') + '/i' ).test( addedNode.innerText ) &&
                            new RegExp( disable_pattern.replace(/(\w)/g, '$1\s*') + '/i' ).test( addedNode.innerText ) ){
                            removeModal( addedNode );
                        }
                    });
                }
            });
        });
        // Observer
        observer.observe(document, {
            childList : true,
            subtree : true
        });
    }, false);


})();