1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Grasemonkey/Tampermonkey Rappers.in Anti Anti Adblock

Discussion in 'Source Code' started by Skyfail, May 8, 2015.

  1. Skyfail

    Skyfail Administrator Staff Member Administrator

    Joined:
    Mar 21, 2013
    Messages:
    854
    Likes Received:
    0
    Unkommentiert und enthält ein haufen copy pasta von Stackoverflow.
    Demo:
    [media]https://www.youtube.com/watch?v=pMGaX86_ifo&feature=youtu.be[/media]
    Code:
    // ==UserScript==
    // @name         Rappers.in Anti Anti Adblock
    // @namespace    https://keller-elite.com
    // @version      0.1
    // @description  Bypasses Rappers.in's Anti Adblock System
    // @author       Skyfail
    // @match        http://www.rappers.in/*/*
    // ==/UserScript==
    
    console.log("[AntiAntiAdblock] Loaded");
    
    var splitLines = document.body.innerHTML.split('\n');
    
    var lineCount = 0;
    var beginPlaylist = 0;
    var beginVoteFrame = 0;
    
    for each(xvar in splitLines)
    {
        lineCount++;
        if(xvar.indexOf("var myPlaylist") > -1)
        {
            if(xvar.indexOf("adblocker.mp3") > -1)
            { continue; }
            
            console.log("[AntiAntiAdblock] Found Playlist line: " + lineCount);
            beginPlaylist = lineCount-1;
        }
        else if(xvar.indexOf('jQuery("#voteframe') > -1 &&
               xvar.indexOf('ADBLOCK') == -1)
        {
            console.log("[AntiAntiAdblock] Found Vote line: " + lineCount);
            beginVoteFrame = lineCount-1;
        }
    }
    
    if(beginVoteFrame > 0)
    {
        var cmd = "";
        for(i = beginVoteFrame; i < lineCount; i++)
        {
            if(splitLines[i].indexOf("}") > -1)
            { break; }
            
            cmd += splitLines[i];
            cmd += "\n";
        }
        eval(cmd);
    }
    
    if(beginPlaylist > 0)
    {
        var cmd = "";
    
    for(i = beginPlaylist; i < lineCount; i++)
    {
        if(splitLines[i].indexOf("jQuery(document") > -1)
        { break; }
        
        if(splitLines[i].indexOf("}") > -1 && splitLines[i].indexOf("})") == -1 && splitLines[i].indexOf("},") == -1)
        { continue; }
        
        cmd += splitLines[i];
        cmd += "\n";
    }
    
    var div = document.getElementById('MyTarget');
    if(div)
    {
        (function (window) {
        var last = +new Date();
        var delay = 100; // default delay
    
        // Manage event queue
        var stack = [];
    
        function callback() {
            var now = +new Date();
            if (now - last > delay) {
                for (var i = 0; i < stack.length; i++) {
                    stack[i]();
                }
                last = now;
            }
        }
    
        // Public interface
        var onDomChange = function (fn, newdelay) {
            if (newdelay) delay = newdelay;
            stack.push(fn);
        };
    
        // Naive approach for compatibility
        function naive() {
    
            var last = document.getElementsByTagName('*');
            var lastlen = last.length;
            var timer = setTimeout(function check() {
    
                // get current state of the document
                var current = document.getElementsByTagName('*');
                var len = current.length;
    
                // if the length is different
                // it's fairly obvious
                if (len != lastlen) {
                    // just make sure the loop finishes early
                    last = [];
                }
    
                // go check every element in order
                for (var i = 0; i < len; i++) {
                    if (current[i] !== last[i]) {
                        callback();
                        last = current;
                        lastlen = len;
                        break;
                    }
                }
    
                // over, and over, and over again
                setTimeout(check, delay);
    
            }, delay);
        }
    
        //
        //  Check for mutation events support
        //
    
        var support = {};
    
        var el = document.documentElement;
        var remain = 3;
    
        // callback for the tests
        function decide() {
            if (support.DOMNodeInserted) {
                window.addEventListener("DOMContentLoaded", function () {
                    if (support.DOMSubtreeModified) { // for FF 3+, Chrome
                        el.addEventListener('DOMSubtreeModified', callback, false);
                    } else { // for FF 2, Safari, Opera 9.6+
                        el.addEventListener('DOMNodeInserted', callback, false);
                        el.addEventListener('DOMNodeRemoved', callback, false);
                    }
                }, false);
            } else if (document.onpropertychange) { // for IE 5.5+
                document.onpropertychange = callback;
            } else { // fallback
                naive();
            }
        }
    
        // checks a particular event
        function test(event) {
            el.addEventListener(event, function fn() {
                support[event] = true;
                el.removeEventListener(event, fn, false);
                if (--remain === 0) decide();
            }, false);
        }
    
        // attach test events
        if (window.addEventListener) {
            test('DOMSubtreeModified');
            test('DOMNodeInserted');
            test('DOMNodeRemoved');
        } else {
            decide();
        }
    
        // do the dummy test
        var dummy = document.createElement("div");
        el.appendChild(dummy);
        el.removeChild(dummy);
    
        // expose
        window.onDomChange = onDomChange;
    })(window);
        
        onDomChange(function(){ 
           var oldPlayer = document.getElementById("Stage_JBEEB_15");
           if(oldPlayer)
           {
               console.log("[AntiAntiAdblock] Found old player, removing.");
               oldPlayer.remove();
           }
    });
    
    }
    
    eval(cmd);
    }