RU AdList JS Fixes

try to take over the world!

26.05.2016 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         RU AdList JS Fixes
// @namespace    ruadlist_js_fixes
// @version      0.1
// @description  try to take over the world!
// @author       lainverse & dimisa
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var qSelect = document.querySelector,
        qSelectAll = document.querySelectorAll,
        nRemove = function(node) {
            node.parentNode.removeChild(node);
        },
        scissors = function(selector, words) {
            var nodes = document.querySelectorAll(selector),
                i = nodes.length,
                ret = false;
            while (i--)
                if (words.test(nodes[i].innerHTML)) {
                    nodes[i].parentNode.removeChild(nodes[i]);
                    ret = true;
                }
            return ret;
        };

    var scripts = {};
    scripts['fs.to'] = function() {
        var divs = document.getElementsByTagName('div');
        var re = /\w{1,5}\d{1,5}\w{1,5}\d{1,5}/;
        for(var i = 0; i < divs.length; i++)
            if(re.test(divs[i].className))
                divs[i].style.display = 'none';

        var style = document.head.appendChild( document.createElement('style') );
        style.type = 'text/css';

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

        if (/\/view_iframe\//i.test(document.location.pathname)) {
            var p = qSelect('#player:not([preload="auto"])'),
                m = qSelect('.main'),
                adStepper = function(p) {
                    if (p.currentTime < p.duration)
                        p.currentTime++;
                },
                cl = function(p) {
                    function skipListener() {
                        p.pause();
                        p.classList.add('m-hidden');
                        setTimeout(adStepper, 1000, p);
                    }
                    p.addEventListener('timeupdate', skipListener, false);
                },
                o = new MutationObserver(function (mut) {
                    mut.forEach(function (e) {
                        for (var i = 0; i < e.addedNodes.length; 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['fishki.net'] = function() {
        scissors('.main-post', /543769|Реклама/);
    };

    scripts['yap.ru'] = function() {
        var words = /member1438|Administration/;
        scissors('form > table[id^="p_row_"]', words);
        var b = qSelectAll('tr > .holder.newsbottom');
        for (var i=0;i<b.length;i++)
            if (words.test(b[i].innerHTML)){
                var row = b[i].parentNode.rowIndex;
                var table = b[i].parentNode.parentNode;
                table.deleteRow(row);
                table.deleteRow(row-1);
                table.deleteRow(row-2);
            }
    };
    scripts['yaplakal.com'] = scripts['yap.ru'];

    scripts['auto.ru'] = function() {
        function check1(sci, i) {
            if (i && !sci('.listing-list > .listing-item, .listing-item_type_fixed.listing-item, div[class*="layout_catalog-inline"], .listing > tbody', /Реклама/))
                setTimeout(check1, 100, sci, i-1);
        }
        function check2(sci, i) {
            if (i && !sci('.sidebar-block, .pager-listing + div[class], div[class$="layout_horizontal"], .card > div[class][style], .sidebar > div[class], .main-page__section + div[class]', /Яндекс\.Директ/))
                setTimeout(check2, 100, sci, i-1);
        }
        check1(scissors, 30);
        check2(scissors, 30);
    };

    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);
    };

    if (document.domain in scripts) {
        scripts[document.domain]();
    } else if ((document.domain.match(/\./g) || empty).length > 2) {
        var domainBlocks = document.domain.split('.'),
            i = domainBlocks.length - 2;
        while(i--) {
            var domain = domainBlocks.slice(-2-i).join('.');
            if (domain in scripts) {
                scripts[domain]();
                break;
            }
        }
    }
})();