Greasy Fork is available in English.

RU AdList JS Fixes

try to take over the world!

Per 06-09-2016. Zie de nieuwste versie.

// ==UserScript==
// @name         RU AdList JS Fixes
// @namespace    ruadlist_js_fixes
// @version      1.3.12
// @description  try to take over the world!
// @author       lainverse & dimisa
// @match        *://*/*
// @grant        unsafeWindow
// @grant        window.close
// @grant        GM_addStyle
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';
    var win = unsafeWindow || window;
    function inIFrame() {
        try {
            return win.self !== win.top;
        } catch (ignore) {
            return true;
        }
    }

    // https://greasyfork.org/scripts/19144-websuckit/
    (function() {
        var scriptText = '';

        function WebSocketWrapper() {
            // check if the browser supports Proxy and WebSocket
            if (typeof Proxy !== 'function' ||
                typeof WebSocket !== 'function') {
                return;
            }
            var to_block = [
                '||24video.xxx',
                '||adlabs.ru',
                '||bgrndi.com^',
                '||brokeloy.com^',
                '||dreadfula.ru^',
                '||et-code.ru^',
                '||free-torrent.org^',
                '||free-torrent.pw^',
                '||free-torrents.org^',
                '||free-torrents.pw^',
                '||game-torrent.info^',
                '||gocdn.ru^',
                '||hghit.com^',
                '||kinotochka.net^',
                '||kuveres.com^',
                '||lepubs.com^',
                '||luxup.ru^',
                '||mail.ru^',
                '||marketgid.com^',
                '||mxtads.com^',
                '||oconner.biz^',
                '||poolnoodle.tech',
                '||psma01.com^',
                '||psma02.com^',
                '||psma03.com^',
                '||recreativ.ru^',
                '||regpole.com^',
                '||skidl.ru^',
                '||torvind.com^',
                '||trafmag.com^',
                '||xxuhter.ru^',
                '||yuiout.online^'
            ];
            var masks = [];
            to_block.forEach(function(m){
                masks.push(new RegExp(
                    m.replace(/([\\\/\[\].*+?(){}$])/g, '\\$1')
                    .replace(/\^(?!$)/g,'\\.?[^\\w%._-]')
                    .replace(/\^$/,'\\.?([^\\w%._-]|$)')
                    .replace(/^\|\|/,'^wss?:\\/+([^\/.]+\\.)*'),
                    'i'));
            });
            var realWS = win.WebSocket,
                closingFunctions = ['close', 'send'];
            function wsGetter(tgt, nm) {
                console.log('[WSI] Registered call to property "', nm, '"');
                try {
                    if (typeof realWS.prototype[nm] === 'function') {
                        if (closingFunctions.indexOf(nm) > -1) {
                            tgt.readyState = realWS.CLOSED;
                        }
                        return function(){return;};
                    }
                    if (typeof realWS.prototype[nm] === 'number') {
                        return realWS[nm];
                    }
                } catch(ignore) {}
                return tgt[nm];
            }
            var _WebSocket = (new Proxy(realWS, {
                construct: function(target, args) {
                    var url = args[0];
                    console.log('[WSI] Opening socket on', url, '\u2026');
                    var i = masks.length;
                    while(i--) {
                        if (masks[i].test(url)) {
                            console.log("[WSI] Blocked.");
                            return new Proxy({url: url, readyState: realWS.OPEN}, {
                                get: wsGetter
                            });
                        }
                    }
                    return new target(args[0], args[1]);
                }
            }));
            win.WebSocket = _WebSocket.bind(win);
        }

        function WorkerWrapper(){
            var wr = win.Worker;
            function Worker(resourceURI) {
                var _promise = new Promise(function(resolve,reject){
                    var xhrLoadEnd = function() {
                        resolve(new wr(URL.createObjectURL(
                            new Blob(['(function(){var win = self;'+
                                      WebSocketWrapper.toString()+
                                      ' WebSocketWrapper();})();'+this.result])
                        )));
                    };
                    var xhr = new XMLHttpRequest();
                    xhr.open('GET', resourceURI, true);
                    xhr.responseType = 'blob';
                    xhr.onload = function(){
                        if (this.status === 200) {
                            var reader = new FileReader();
                            reader.addEventListener("loadend", xhrLoadEnd);
                            reader.readAsText(this.response);
                        }
                    };
                    xhr.send();
                });
                var _worker = null,
                    _terminate = false,
                    _onerror = null,
                    _onmessage = null,
                    _messages = [],
                    _events = [];
                var setWorker = function(val) {
                    _worker = val;
                    _worker.onerror = _onerror;
                    _worker.onmessage = _onmessage;
                    var _e;
                    while(_events.length) {
                        _e = _events.shift();
                        _worker[_e[0]].apply(_worker, _e[1]);
                    }
                    while(_messages.length) {
                        _worker.postMessage(_messages.shift());
                    }
                    if (_terminate) {
                        _worker.terminate();
                    }
                };
                _promise.then(setWorker);
                this.terminate = function(){
                    _terminate = true;
                    if (_worker) {
                        _worker.terminate();
                    }
                };
                Object.defineProperty(this, 'onmessage', {
                    get:function(){
                        return _onmessage;
                    },
                    set:function(val){
                        _onmessage = val;
                        if (_worker) {
                            _worker.onmessage = val;
                        }
                    }
                });
                Object.defineProperty(this, 'onerror', {
                    get:function(){
                        return _onerror;
                    },
                    set:function(val){
                        _onerror = val;
                        if (_worker) {
                            _worker.onmessage = val;
                        }
                    }
                });
                this.postMessage = function(message){
                    if (_worker) {
                        _worker.postMessage(message);
                    } else {
                        _messages.push(message);
                    }
                };
                this.terminate = function() {
                    _terminate = true;
                    if (_worker) {
                        _worker.terminate();
                    }
                };
                this.addEventListener = function(){
                    if (_worker) {
                        _worker.addEventListener.apply(_worker, arguments);
                    } else {
                        _events.push(['addEventListener',arguments]);
                    }
                };
                this.removeEventListener = function(){
                    if (_worker) {
                        _worker.removeEventListener.apply(_worker, arguments);
                    } else {
                        _events.push(['removeEventListener',arguments]);
                    }
                };
            }
            win.Worker = Worker.bind(window);
        }

        function CreateElementWrapper() {
            var _ce = document.createElement.bind(document),
                dataText = /^data:text/i,
                key = '"'+Math.random().toString(36).substr(2)+'";',
                eskey = escape(key);
            function frameRewrite(e) {
                var f = e.target;
                if(dataText.test(f.src) && f.src.indexOf(eskey) < 0) {
                    f.src = f.src.replace(',',','+escape('<scr'+'ipt>'+key+scriptText+'</scr'+'ipt>'));
                }
            }
            function createElement(name) {
                if (name && name.toUpperCase &&
                    name.toUpperCase() === 'IFRAME') {
                    var ifr = _ce.apply(document, arguments);
                    ifr.addEventListener('load', frameRewrite, false);
                    return ifr;
                }
                return _ce.apply(document, arguments);
            }
            document.createElement = createElement.bind(document);
        }

        function GenerateScriptText() {
            scriptText = '(function(){var win = self||window, scriptText = "";'+
                WebSocketWrapper.toString()+
                WorkerWrapper.toString()+
                CreateElementWrapper.toString()+
                GenerateScriptText.toString()+
                'GenerateScriptText();'+
                'WebSocketWrapper();'+
                'WorkerWrapper();'+
                'CreateElementWrapper();'+
                '})();'+
                'var s = document.currentScript; if (s) {s.parentNode.removeChild(s);}';
        }

        GenerateScriptText();
        scriptText = scriptText.replace(/\/\/[^\r\n]*/g,'').replace(/[\s\r\n]+/g,' ');

        if (/firefox/i.test(navigator.userAgent)) {
            var script = document.createElement('script');
            script.appendChild(document.createTextNode(scriptText));
            document.head.insertBefore(script,document.head.firstChild);
            return; //we don't want to call functions on page from here in Fx, so exit
        }

        WebSocketWrapper();
        WorkerWrapper();
        CreateElementWrapper();
    })();

    if (!(/firefox/i.test(navigator.userAgent))) { // scripts for non-Firefox browsers

        // https://greasyfork.org/scripts/14720-it-s-not-important
        (function(){
            var imptt = /((display|(margin|padding)(-top|-bottom)?)\s*:[^;!]*)!\s*important/ig;

            function unimportanter(el, si) {
                if (!imptt.test(si) || el.style.display === 'none') {
                    return 0; // get out if we have nothing to do here
                }
                if (el.nodeName === 'IFRAME' && el.src &&
                    el.src.slice(0,17) === 'chrome-extension:') {
                    return 0; // Web of Trust uses this method to add their frame
                }
                var so = si.replace(imptt, function(){return arguments[1];}), ret = 0;
                if (si !== so) {
                    ret = 1;
                    el.setAttribute('style', so);
                }
                return ret;
            }

            function logger(c) {
                if (c) {
                    console.log('Some page elements became a bit less important.');
                }
            }

            function checkTarget(m, c) {
                var si = m.getAttribute ? m.getAttribute('style') : null;
                if (si && si.indexOf('!') > -1) {
                    c += unimportanter(m, si);
                }
                return c;
            }

            function checkNodes(m, c) {
                var i = m.length;
                while(i--) {
                    c = checkTarget(m[i], c);
                }
                return c;
            }

            var observer = new MutationObserver(function(mutations) {
                setTimeout(function(m) {
                    var i = m.length, c = 0;
                    while(i--) {
                        if (m[i].target) {
                            c = checkTarget(m[i].target, c);
                        }
                        if (m[i].addedNodes.length) {
                            c = checkNodes(m[i].addedNodes, c);
                        }
                    }
                    logger(c);
                },0,mutations);
            });

            observer.observe(document, { childList : true, attributes : true, attributeFilter : ['style'], subtree : true });

            win.addEventListener ("load", function(){
                var c = 0, imp = document.querySelectorAll('[style*="!"]'), i = imp.length;
                while(i--) {
                    c+= checkTarget(imp[i], c);
                }
                logger(c);
            }, false);
        })();

    }

    if (/^https?:\/\/(news\.yandex\.|(www\.)?yandex\.[^\/]+\/(yand)?search[\/?])/i.test(win.location.href)) {
        // https://greasyfork.org/en/scripts/809-no-yandex-ads
        (function(){
            var adWords = ['Яндекс.Директ','Реклама','Ad'];
            function remove(node) {
                node.parentNode.removeChild(node);
            }
            // Generic ads removal and fixes
            function removeGenericAds() {
                var s, i;
                s = document.querySelector('.serp-header');
                if (s) {
                    s.style.marginTop='0';
                }
                s = document.querySelectorAll('.serp-adv__head + .serp-item');
                i = s.length;
                while(i--) {
                    s[i].parentNode.removeChild(s[i]);
                }
                s = document.querySelectorAll('#adbanner, .serp-adv, .b-spec-adv, div[class*="serp-adv__"]');
                i = s.length;
                while(i--) {
                    remove(s[i]);
                }
            }
            // Search ads
            function removeSearchAds() {
                var s = document.querySelectorAll('.serp-block, .serp-item, .search-item');
                var i = s.length, item;
                while(i--) {
                    item = s[i].querySelector('.label, .serp-item__label, .document__provider-name');
                    if (item && adWords.indexOf(item.textContent) > -1) {
                        remove(s[i]);
                        console.log('Ads removed.');
                    }
                }
            }
            // News ads
            function removeNewsAds() {
                var s = document.querySelectorAll('.page-content__left > *,.page-content__right > *:not(.page-content__col),.page-content__right > .page-content__col > *');
                var i = s.length;
                while(i--) {
                    if (s[i].textContent.indexOf(adWords[0]) > -1) {
                        remove(s[i]);
                        console.log('Ads removed.');
                    }
                }
            }
            // News fixes
            function removePageAdsClass() {
                if (document.body.classList.contains("b-page_ads_yes")){
                    document.body.classList.remove("b-page_ads_yes");
                    console.log('Page ads class removed.');
                }
            }
            // Function to attach an observer to monitor dynamic changes on the page
            function pageUpdateObserver(func, obj, params) {
                if (obj) {
                    var o = new MutationObserver(func);
                    o.observe(obj,(params || {childList:true, subtree:true}));
                }
            }
            // Cleaner
            document.addEventListener ("DOMContentLoaded", function() {
                removeGenericAds();
                if (win.location.hostname.search(/^news\./i) === 0) {
                    pageUpdateObserver(removeNewsAds, document.querySelector('BODY'));
                    pageUpdateObserver(removePageAdsClass, document.body, {attributes:true, attributesFilter:['class']});
                    removeNewsAds();
                    removePageAdsClass();
                } else {
                    pageUpdateObserver(removeSearchAds, document.querySelector('.main__content'));
                    removeSearchAds();
                }
            });
        })();
        return; //skip fixes for other sites
    }

    // https://greasyfork.org/en/scripts/14470-4pda-unbrender
    if (/(^|\.)4pda\.ru$/i.test(window.location.hostname)) {
        (function(){
            var isForum = document.location.href.search('/forum/') !== -1,
                isSafari = (/Safari/i.test(navigator.userAgent)) && (/Apple\sComputer/i.test(navigator.vendor)),
                hStyle;

            function remove(n) {
                if (n) {
                    n.parentNode.removeChild(n);
                }
            }

            function afterClean() {
                hStyle.disabled = true;
                remove(hStyle);
            }

            function beforeClean() {
                // attach styles before document displayed
                hStyle = document.createElement('style');
                hStyle.id = 'ubrHider';
                hStyle.type = 'text/css';
                document.head.appendChild(hStyle);

                hStyle.sheet.insertRule('html { overflow-y: scroll }', 0);
                hStyle.sheet.insertRule('article + aside * { display: none !important }', 0);
                hStyle.sheet.insertRule('#header + div:after {'+(
                    'content: "";'+
                    'position: fixed;'+
                    'top: 0;'+
                    'left: 0;'+
                    'width: 100%;'+
                    'height: 100%;'+
                    'background-color: #E6E7E9'
                )+'}', 0);
                // http://codepen.io/Beaugust/pen/DByiE
                hStyle.sheet.insertRule('@keyframes spin { 100% { transform: rotate(360deg) } }', 0);
                hStyle.sheet.insertRule('article + aside:after {'+(
                    'content: "";'+
                    'position: absolute;'+
                    'width: 150px;'+
                    'height: 150px;'+
                    'top: 150px;'+
                    'left: 50%;'+
                    'margin-top: -75px;'+
                    'margin-left: -75px;'+
                    'box-sizing: border-box;'+
                    'border-radius: 100%;'+
                    'border: 10px solid rgba(0, 0, 0, 0.2);'+
                    'border-top-color: rgba(0, 0, 0, 0.6);'+
                    'animation: spin 2s infinite linear'
                )+'}', 0);

                // display content of a page if time to load a page is more than 2 seconds to avoid
                // blocking access to a page if it is loading for too long or stuck in a loading state
                setTimeout(2000, afterClean);
            }

            GM_addStyle('#nav .use-ad {display: block !important;} ' +
                        'article:not(.post) + article:not(#id) { display: none !important }');
            if (!isForum && !isSafari) {
                beforeClean();
            }

            // clean the page
            window.addEventListener('DOMContentLoaded', function(){
                var rem, si, lst, i;
                function width(){ return window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0; }
                function height(){ return window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0; }


                if (isForum) {
                    si = document.querySelector('#logostrip');
                    if (si) {
                        remove(si.parentNode.nextSibling);
                    }
                }

                if (document.location.href.search('/forum/dl/') !== -1) {
                    lst = document.querySelectorAll('body>div');
                    i = lst.length;
                    document.body.setAttribute('style', (document.body.getAttribute('style')||'')+
                                               ';background-color:black!important');
                    while (i--) {
                        if (!lst[i].querySelector('.dw-fdwlink')) {
                            remove(lst[i]);
                        }
                    }
                }

                if (isForum) { // Do not continue if it's a forum
                    return;
                }

                si = document.querySelector('#header');
                if (si) {
                    rem = si.previousSibling;
                    while (rem) {
                        si = rem.previousSibling;
                        remove(rem);
                        rem = si;
                    }
                }

                lst = document.querySelectorAll('#nav li[class]');
                i = lst.length;
                while (i--) {
                    if (lst[i] && lst[i].querySelector('a[href^="/tag/"]')) {
                        remove(lst[i]);
                    }
                }

                lst = document.querySelectorAll('DIV');
                i = lst.length;
                var style, result;
                while (i--) {
                    if (lst[i].offsetWidth > 0.95 * width() && lst[i].offsetHeight > 0.9 * height()) {
                        style = window.getComputedStyle(lst[i], null);
                        result = [];
                        if(style.backgroundImage !== 'none') {
                            result.push('background-image:none!important');
                        }
                        if(style.backgroundColor !== 'transparent') {
                            result.push('background-color:transparent!important');
                        }
                        if (result.length) {
                            if (lst[i].getAttribute('style')) {
                                result.unshift(lst[i].getAttribute('style'));
                            }
                            lst[i].setAttribute('style', result.join(';'));
                        }
                    }
                }

                lst = document.querySelectorAll('ASIDE>DIV');
                i = lst.length;
                while (i--) {
                    if ( ((lst[i].querySelector('script, iframe, a[href*="/ad/www/"]') ||
                           lst[i].querySelector('img[src$=".gif"]:not([height="0"]), img[height="400"]')) &&
                          !lst[i].classList.contains('post') ) || !lst[i].childNodes.length ) {
                        remove(lst[i]);
                    }
                }

                document.body.setAttribute('style', (document.body.getAttribute('style')||'')+';background-color:#E6E7E9!important');

                // display content of the page
                afterClean();
            });
        })();
        return;
    }

    // https://greasyfork.org/en/scripts/21937-moonwalk-hdgo-kodik-fix
    (function () {
        if (!inIFrame) {
            return;
        }

        document.addEventListener ("DOMContentLoaded", function() {
            var player;
            if (win.iframe_adv_enabled !== undefined) {
                win.iframe_adv_enabled = false;
            } else if (win.banner_second !== undefined) {
                win.banner_second = 0;
                player = document.getElementById('play-player-hd');
                if (player) {
                    player.onclick = function() {
                        var adsdiv = document.getElementById("ads-player-hd");
                        adsdiv.parentNode.removeChild(adsdiv);
                        win.setPlayer();
                    };
                }
            } else if (win.MXoverrollCallback !== undefined) {
                player = document.getElementsByClassName('play_button')[0];
                if (player) {
                    player.onclick = win.MXoverrollCallback.bind(window);
                }
            }
        },false);
    })();
    // hdgo.cc/couber.be fix
    (function(){
        var hdgoDomains = ['couber.be','hdgo.cc','46.30.43.38'];
        if (hdgoDomains.indexOf(document.domain) > -1) {
            Object.defineProperty(win, 'canRunAds', {
                value: true,
                configurable: false,
                enumerable: false,
                writable: false
            });
        }
    })();

    document.addEventListener ("DOMContentLoaded", function() {
        // function to search and remove nodes by content
        // selector - standard CSS selector to define set of nodes to check
        // words - regular expression to check content of the suspicious nodes
        // params - object with multiple extra parameters:
        //   .hide - set display to none instead of removing from the page
        //   .parent - parent node to remove if content is found in the child node
        //   .siblings - number of simling nodes to remove (excluding text nodes)
        function scRemove(e) {e.parentNode.removeChild(e);}
        function scHide(e) {e.style.display='none';}
        function scissors (selector, words, scope, params) {
            var remFunc = (params.hide ? scHide : scRemove),
                iterFunc = (params.siblings > 0 ?
                            'nextSibling' :
                            'previousSibling'),
                nodes = scope.querySelectorAll(selector),
                i = nodes.length,
                toRemove = [],
                siblings,
                node;
            while(i--) {
                node = nodes[i];
                if (words.test(node.innerHTML) || !node.childNodes.length) {
                    // drill up to the specified parent node if required
                    if (params.parent) {
                        while(node !== scope && !(node.matches(params.parent))) {
                            node = node.parentNode;
                        }
                    }
                    if (node === scope) {
                        break;
                    }
                    toRemove.push(node);
                    // add multiple nodes if defined more than one sibling
                    siblings = Math.abs(params.siblings) || 0;
                    while (siblings) {
                        node = node[iterFunc];
                        toRemove.push(node);
                        if (node.nodeType === 1) {
                            siblings -= 1; //count only element nodes
                        }
                    }
                }
            }
            i = toRemove.length;
            while(i--) {
                remFunc(toRemove[i]);
            }

            return toRemove.length;
        }

        // function to perform multiple checks if ads inserted with a delay
        // by default does 30 checks withing a 3 seconds unless nonstop mode specified
        // also does 1 extra check when a page completely loads
        // selector and words - passed dow to scissors
        // params - object with multiple extra parameters:
        //   .root - selector to narrow down scope to scan;
        //   .observe - if true then check will be performed continuously;
        // Other parameters passed down to scissors.
        function gardener(selector, words, params) {
            params = params || {};
            var scope = document.body,
                nonstop = false;
            // narrow down scope to a specific element
            if (params.root) {
                scope = scope.querySelector(params.root);
                if (!scope) {// exit if the root element is not present on the page
                    return 0;
                }
            }
            // add observe mode if required
            if (params.observe) {
                if (typeof MutationObserver === 'function') {
                    var o = new MutationObserver(function(ms){
                        ms.forEach(function(m){
                            if (m.addedNodes.length) {
                                scissors(selector, words, scope, params);
                            }
                        });
                    });
                    o.observe(scope, {childList:true, subtree: true});
                } else {
                    nonstop = true;
                }
            }
            // wait for a full page load to do one extra cut
            win.addEventListener('load',function(){
                scissors(selector, words, scope, params);
            });
            // do multiple cuts until ads removed
            function cut(sci, s, w, sc, p, i) {
                if (i > 0) {
                    i -= 1;
                }
                if (i && !sci(s, w, sc, p)) {
                    setTimeout(cut, 100, sci, s, w, sc, p, i);
                }
            }
            cut(scissors, selector, words, scope, params, (nonstop ? -1 : 30));
        }

        function preventBackgroundRedirect() {
            console.log("Background redirect prevention enabled.");
            var orgOpen = win.open;
            win.open = function(){
                var loc = arguments[0];
                if (loc.indexOf(win.location.host) > -1 ||
                    loc.indexOf('://') === -1) {
                    win.addEventListener('unload',function(){
                        win.close();
                    }, true);
                }
                orgOpen.apply(window, arguments);
            };
        }

        var scripts = {};
        scripts['fs.to'] = function() {
            function skipClicker(i) {
                if (!i) {
                    return;
                }
                var skip = document.querySelector('.b-aplayer-banners__close');
                if (skip) {
                    skip.click();
                } else {
                    setTimeout(skipClicker, 100, i-1);
                }
            }
            setTimeout(skipClicker, 100, 30);

            (function(){
                var divs = document.getElementsByTagName('div'),
                    re = /^b-[a-z]+\d+[a-z\d]*\s*$/,
                    i = divs.length;
                while(i--) {
                    if (re.test(divs[i].className)) {
                        divs[i].style.display = 'none';
                    }
                }
            })();

            GM_addStyle('.b-aplayer-teasers > a, div[class^="b-adproxy"], div[id^="admixer_async_"],'+
                        '.b-player-popup__content > div[class][style="position: relative;"]'+
                        '{display:none!important}');

            if (/\/(view_iframe|iframeplayer)\//i.test(document.location.pathname)) {
                var p = document.querySelector('#player:not([preload="auto"])'),
                    m = document.querySelector('.main'),
                    adStepper = function(p) {
                        if (p.currentTime < p.duration) {
                            p.currentTime += 1;
                        }
                    },
                    adSkipper = function(f, p) {
                        f.click();
                        p.waitAfterSkip = false;
                        p.longerSkipper = false;
                        console.log('Пропустили.');
                    },
                    cl = function(p) {
                        var faster = document.querySelector('.b-aplayer__html5-desktop-skip'),
                            series = document.querySelector('.b-aplayer__actions-series');

                        function clickSelected() {
                            var s = document.querySelector('.b-aplayer__popup-series-episodes .selected a');
                            if (s) {
                                s.click();
                            }
                        }

                        if ((!faster || faster.style.display !== 'block') && series && !p.seriesClicked) {
                            series.click();
                            p.seriesClicked = true;
                            p.longerSkipper = true;
                            setTimeout(clickSelected, 1000);
                            p.pause();
                        }

                        function skipListener() {
                            if (p.waitAfterSkip) {
                                console.log('В процессе пропуска…');
                                return;
                            }
                            p.pause();
                            if (!p.classList.contains('m-hidden')) {
                                p.classList.add('m-hidden');
                            }
                            if (faster && p.currentTime &&
                                win.getComputedStyle(faster).display === 'block' &&
                                !faster.querySelector('.b-aplayer__html5-desktop-skip-timer')) {
                                p.waitAfterSkip = true;
                                setTimeout(adSkipper, (p.longerSkipper?3:1)*1000, faster, p);
                                console.log('Доступен быстрый пропуск…');
                            } else {
                                setTimeout(adStepper, 1000, p);
                            }
                        }

                        p.addEventListener('timeupdate', skipListener, false);
                    },
                    o = new MutationObserver(function (mut) {
                        mut.forEach(function (e) {
                            var i = e.addedNodes.length;
                            while(i--) {
                                if (e.addedNodes[i].id === 'player' &&
                                    e.addedNodes[i].nodeName === 'VIDEO' &&
                                    e.addedNodes[i].getAttribute('preload') !== 'auto') {
                                    cl(e.addedNodes[i]);
                                }
                            }
                        });
                    });
                if (p.nodeName === 'VIDEO') {
                    cl(p);
                } else {
                    o.observe(m, {childList: true});
                }
            }
        };
        scripts['brb.to'] = scripts['fs.to'];
        scripts['cxz.to'] = scripts['fs.to'];

        scripts['drive2.ru'] = function() {
            gardener('.c-block', />Реклама<\/|\.relap\..*display:\s?none/i);
        };

        scripts['fishki.net'] = function() {
            gardener('.main-post', /543769|Реклама/);
        };

        scripts['hdrezka.me'] = function() {
            gardener('div[id][onclick][onmouseup][onmousedown]', /onmouseout/i);
        };

        scripts['naruto-base.su'] = function() {
            gardener('div[id^="entryID"],.block', /href="http.*?target="_blank"/i);
        };

        scripts['pb.wtf'] = function() {
            GM_addStyle('#result,tbody.row1:not([id]) {display: none !important}');
            gardener('a[href$="=="]', /img/i, {root:'#page_container .containe', observe:true, parent:'div[class]'});
            gardener('a[href^="/"]', /<img\s.*<br>/i, {root:'#main_content', observe:true, parent:'div[class]'});
            gardener('.re_top1', /./, {root:'#main_content', parent:'table.border'});
        };
        scripts['piratbit.org'] = scripts['pb.wtf'];
        scripts['piratbit.ru'] = scripts['pb.wtf'];

        scripts['pikabu.ru'] = function() {
            gardener('.story', /story__sponsor|story__gag|profile\/ads"/i, {root: '.inner_wrap', observe: true});
        };

        scripts['rustorka.com'] = function() {
            var s = document.head.childNodes, i = s.length;
            if (i < 5) {
                while(i--) {
                    if (s[i].httpEquiv && s[i].httpEquiv === 'refresh') {
                        win.close();
                    }
                }
            }
            gardener('span[class],ul[class],span[id],ul[id]', /\/\d{12,}\.php/i, {root:'#sidebar1', observe:true});
            gardener('div[id][style*="!important"]', /!important/i);
        };
        scripts['rumedia.ws'] = scripts['rustorka.com'];

        scripts['sports.ru'] = function() {
            gardener('.aside-news-list__item', /aside-news-list__advert/i, {root:'.aside-news-block'});
        };

        scripts['yap.ru'] = function() {
            var words = /member1438|Administration/;
            gardener('form > table[id^="p_row_"]', words);
            gardener('tr > .holder.newsbottom', words, {parent:'tr', siblings:-2});
        };
        scripts['yaplakal.com'] = scripts['yap.ru'];

        scripts['reactor.cc'] = function() {
            preventBackgroundRedirect();
            gardener('a[href="/donate"]', /100/i, {parent:'#content,#sidebar', root:'#pageinner', observe:true});
        };
        scripts['joyreactor.cc'] = scripts['reactor.cc'];
        scripts['pornreactor.cc'] = scripts['reactor.cc'];

        scripts['auto.ru'] = function() {
            var words = /Реклама|Яндекс.Директ|yandex_ad_/;
            var userAdsListAds = [
                '.listing-list > .listing-item',
                '.listing-item_type_fixed.listing-item'
            ];
            var catalogAds = [
                'div[class*="layout_catalog-inline"]',
                'div[class$="layout_horizontal"]'
            ];
            var otherAds = [
                '.advt_auto',
                '.sidebar-block',
                '.pager-listing + div[class]',
                '.card > div[class][style]',
                '.sidebar > div[class]',
                '.main-page__section + div[class]',
                '.listing > tbody'];
            gardener(userAdsListAds.join(','), words, {root:'.listing-wrap', observe:true});
            gardener(catalogAds.join(','), words, {root:'.catalog__page,.content__wrapper', observe:true});
            gardener(otherAds.join(','), words);
        };

        scripts['online.anidub.com'] = function() {
            var script = document.createElement('script');
            script.type = "text/javascript";
            script.innerHTML = "function ogonekstart1() {}";
            document.getElementsByTagName('head')[0].appendChild(script);

            var style = document.createElement('style');
            style.type = 'text/css';
            style.appendChild(document.createTextNode('.background {background: none!important;}'));
            style.appendChild(document.createTextNode('.background > script + div, .background > script ~ div:not([id]):not([class]) + div[id][class] {display:none!important}'));
            document.head.appendChild(style);
        };

        scripts['rsload.net'] = function() {
            win.addEventListener('load', function() {
                var dis = document.querySelector('.cb-disable');
                if (dis) {
                    dis.click();
                }
            });
            document.addEventListener('click',function(e){
                var t = e.target;
                if (t && t.href && (/:\/\/\d+\.\d+\.\d+\.\d+\//.test(t.href))) {
                    t.href = t.href.replace('://','://rsload.net:rsload.net@');
                }
            });
        };

        scripts['imageban.ru'] = function() {
            preventBackgroundRedirect();
            win.addEventListener('unload', function() {
                if (!window.location.hash) {
                    window.location.replace(window.location+'#');
                } else {
                    window.location.hash = '';
                }
            }, true);
        };

        var domain = document.domain;
        while (domain.indexOf('.') !== -1) {
            if (scripts.hasOwnProperty(domain)) {
                scripts[domain]();
                break;
            }
            domain = domain.slice(domain.indexOf('.') + 1);
        }
    });
})();