Assassinate Ad Block Blockers

You know those annoying content blockers that popup demanding you remove your AdBlock so you can read the content? This script removes them by force. Please note, this is not UNIVERSAL like AdBlock Plus. It operates at a per-site basis.

目前為 2020-04-17 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Assassinate Ad Block Blockers
// @namespace    http://tampermonkey.net/
// @version      1.19
// @description  You know those annoying content blockers that popup demanding you remove your AdBlock so you can read the content? This script removes them by force. Please note, this is not UNIVERSAL like AdBlock Plus. It operates at a per-site basis.
// @author       Kxmode
// @run-at       document-idle
// @match        *://www.vg247.com/*
// @match        *://www.eurogamer.net/*
// @match        *://www.makeuseof.com/*
// @match        *://www.gamesradar.com/*
// @match        *://www.usatoday.com/*
// @match        *://www.cnn.com/*
// @match        *://www.businessinsider.com/*
// @match        *://www.thedailybeast.com/*
// @match        *://www.forbes.com/*
// @match        *://*.nytimes.com/*
// ==/UserScript==

// Loads jQuery and triggers a callback function when jQuery has finished loading
function addJQuery(callback) {
    var script = document.createElement("script");
    script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js");
    script.addEventListener('load', function() { callback(); }, false);
    document.body.appendChild(script);
}

// The main script
function main() {

    const $ = (unsafeWindow || window).$;

    // For domains that follow the standard way of blocking AdBlockers typically with a full-page block and overlay.
    var arrayStandardBlockerDomains = [ "www.vg247.com",
                                        "www.eurogamer.net",
                                        "www.gamesradar.com",
                                        "www.usatoday.com",
                                        "www.cnn.com"].map(String);

    // For domains that follow a nonstandard way of blocking AdBlockers by typically blocking the content area only, or some other unique way.
    var arrayAbnormalBlockerDomains = [ "www.makeuseof.com",
                                        "www.businessinsider.com",
                                        "www.thedailybeast.com",
                                        "www.nytimes.com",
                                        "cooking.nytimes.com",
                                        "www.forbes.com"].map(String);

    // For domains that typically launch third-party modals for random stuff like sign-ups.
    var arrayAuxiliaryBlockerDomains = [ "www.gamesradar.com"].map(String);

    /*
    // keeping for future use
    function DomainCheck() {
        var i, domain = window.location.hostname;
        for (i = 0; i < arrayStandardBlockerDomains.length; i++)
        {
            if (domain == arrayStandardBlockerDomains[i])
            {
                return arrayStandardBlockerDomains[i];
                break;
            }
        }
        for (i = 0; i < arrayAbnormalBlockerDomains.length; i++)
        {
            if (domain == arrayAbnormalBlockerDomains[i])
            {
                return arrayAbnormalBlockerDomains[i];
                break;
            }
        }
        for (i = 0; i < arrayAuxiliaryBlockerDomains.length; i++)
        {
            if (domain == arrayAuxiliaryBlockerDomains[i])
            {
                return arrayAuxiliaryBlockerDomains[i];
                break;
            }
        }
    }
    var domain = DomainCheck();
    */

    function DOMStatusCheck() {
        if (arrayStandardBlockerDomains.indexOf(window.location.hostname) > -1)
        {
            var isHTMLBlocked = $("html").attr("style");
            var isBodyBlocked = $("body").attr("style");
            var isHTMLClassBlocked = $("html").hasClass("sp-message-open");

            if (isHTMLBlocked !== undefined || isBodyBlocked !== undefined || isHTMLClassBlocked)
            {
                clearInterval(currentStatus1);
                // We're on a page that is blocked

                $("html").removeAttr("style");
                $("body").removeAttr("style");
                $("html").removeClass("sp-message-open");

                switch(window.location.hostname)
                {
                    case arrayStandardBlockerDomains[0]: // vg247
                    case arrayStandardBlockerDomains[1]: // eurogamer
                    case arrayStandardBlockerDomains[2]: // gamesradar
                    case arrayStandardBlockerDomains[3]: // usatoday
                    case arrayStandardBlockerDomains[4]: // cnn
                        $("[class*='sp_veil']").remove();
                        $("[id*='sp_message_id']").remove();
                        break;
                }
            }

            console.clear();
        }

        if (arrayAuxiliaryBlockerDomains.indexOf(window.location.hostname) > -1)
        {
            switch(window.location.hostname)
            {
                case arrayAuxiliaryBlockerDomains[0]: // gamesradar
                    if ($(".raleigh-optin-visible").is(":visible"))
                    {
                        $("[class*='raleigh-optin-']").remove();
                    }
                    clearInterval(currentStatus2);
                    break;
            }
        }

        if (arrayAbnormalBlockerDomains.indexOf(window.location.hostname) > -1)
        {
            switch(window.location.hostname)
            {
                case arrayAbnormalBlockerDomains[0]: // makeuseof
                    $("[class*='unblockplease-overlay']").remove();
                    $(".unblockplease").removeAttr("style");
                    break;
                case arrayAbnormalBlockerDomains[1]: // businessinsider
                    $(".tp-modal").remove();
                    $(".tp-backdrop").remove();
                    $("body").removeClass("tp-modal-open");
                    break;
                case arrayAbnormalBlockerDomains[3]: // nytimes
                case arrayAbnormalBlockerDomains[4]: // nytimes cooking
                    // nytimes
                    $("#standalone-footer").remove();
                    $("#gateway-content").remove();
                    $("body").attr("style", "overflow: unset;");
                    $("#site-content").attr("style","position: unset;");
                    $("[id*='lire-ui-'").remove();
                    $("[class*='css-1bd']").remove();

                    // nytimes' cooking
                    $(".nytc---modal-window---windowContainer").parents("#appContainer").remove(); // a modal with no close button. wtf nyt?!
                    $("#container").attr("style","overflow: unset;");
                    $(".nytc---modal-window---noScroll").attr("style","overflow: unset;");
                    $("#site-content").attr("style","position: unset;");

                    // nytimes' magazine and site-wide
                    $("[class*='css-mcm']").attr("style","position: unset;");
                    break;
               case arrayAbnormalBlockerDomains[5]: // forbes
                    $(".page-loaded").remove();
                    $(".article-fixed[_nghost-c11]").attr("style", "position: unset;");
                    // abnormal situation. these appear on certain pages but including in the full scope of forbes for good measure.
                    $("#lightboxjs-lightboxlib").remove();
                    $("#aax_prefetch_frame").remove();
                    $("#cok_aax").remove();
                    $("body > iframe:nth-of-type(1)").remove(); // these run in sequence. we want to remove the first 7-9 iframes since iframes typically contain ABB-related injection code or advertisements.
                    $("body > iframe:nth-of-type(1)").remove();
                    $("body > iframe:nth-of-type(1)").remove();
                    $("body > iframe:nth-of-type(1)").remove();
                    $("body > iframe:nth-of-type(1)").remove();
                    $("body > iframe:nth-of-type(1)").remove();
                    $(".fbs-auth__container").remove();
                    $(".fbs-ad--ntv-contentd-wrapper").remove();
                    $(".body--no-scroll").attr("style", "overflow: unset;");
                    $.each($("script"), function() { // scans all scripts for a very specific paywall script
                        var selector = $(this).attr("src");
                        var target = String(selector).match(/(paywall)+.(unlock-protocol)+./g); // the script is found
                        if (target !== null)
                        {
                            $(this).remove(); // and removed so that it can't re-inject itself
                        }
                    });
                    $("#article-container-0").attr("style","position: unset;");
                    break;
            }
        }

    }

    function SledgehammerRemoval() {
        if (window.location.hostname == arrayAbnormalBlockerDomains[2]) // dailybeast
        {
            $(".tp-modal").remove();
            $(".tp-backdrop").remove();
            $("body").removeClass("tp-modal-open");
            $("[id*='offer-0-']").remove();
            $("[displayname*='PianoTag']").remove();
            $("[src*='tinypass.min.js']").remove();
            $("#piano_bottom_ribbon_wrapper").remove();
            console.clear();
            console.log("blocker code removed");
        }
    }

    SledgehammerRemoval();

    function ClearAllIntervals()
    {
        console.clear();
        var totalTimeouts = 10;

        if (window.location.hostname != arrayAbnormalBlockerDomains[2]) // dailybeast
        {
            if (window.location.hostname == arrayAbnormalBlockerDomains[3] || window.location.hostname == arrayAbnormalBlockerDomains[4]) // nytimes and nytimes cooking
            {
                console.log("Final pass for nytimes");
                $("[class*='css-1bd']").remove();
            }
            if (window.location.hostname == arrayAbnormalBlockerDomains[5]) // forbes
            {
                console.log("Final pass for forbes");
                $(".unlock.start").remove();
                $("#article-container-0").attr("style","position: unset;");
            }
            clearInterval("SledgehammerRemoval");
            console.log("Sledgehammer interval cleared");
        }
        for (var i = 1; i <= totalTimeouts; i++)
        {
            var intervalName = "currentStatus" + i;
            clearInterval(intervalName);
        }
        clearInterval(ci);
        console.log("all intervals cleared");
    }

    // Sets up listeners to supercede any blocker shenanigans
    if (arrayStandardBlockerDomains.indexOf(window.location.hostname) > -1) { var currentStatus1 = setInterval(DOMStatusCheck, 50); }
    if (arrayAuxiliaryBlockerDomains.indexOf(window.location.hostname) > -1) { var currentStatus2 = setInterval(DOMStatusCheck, 50); }

    // Second pass after 1.5 seconds
    if (arrayStandardBlockerDomains.indexOf(window.location.hostname) > -1) { var currentStatus3 = setTimeout(DOMStatusCheck, 1500); }
    if (arrayAbnormalBlockerDomains.indexOf(window.location.hostname) > -1) { var currentStatus4 = setTimeout(DOMStatusCheck, 1500); }

    // Third pass after 2.5 seconds
    if (arrayStandardBlockerDomains.indexOf(window.location.hostname) > -1) { var currentStatus5 = setTimeout(DOMStatusCheck, 2500); }
    if (arrayAbnormalBlockerDomains.indexOf(window.location.hostname) > -1) { var currentStatus6 = setTimeout(DOMStatusCheck, 2500); }

    // Fourth pass after 5.5 seconds
    if (arrayStandardBlockerDomains.indexOf(window.location.hostname) > -1) { var currentStatus7 = setTimeout(DOMStatusCheck, 5500); }
    if (arrayAbnormalBlockerDomains.indexOf(window.location.hostname) > -1) { var currentStatus8 = setTimeout(DOMStatusCheck, 5500); }

    // Fifth pass after 7 seconds
    if (arrayStandardBlockerDomains.indexOf(window.location.hostname) > -1) { var currentStatus9 = setTimeout(DOMStatusCheck, 7000); }
    if (arrayAbnormalBlockerDomains.indexOf(window.location.hostname) > -1) { var currentStatus10 = setTimeout(DOMStatusCheck, 7000); }

    // Last-pass guarantee after 7.05 seconds (We want this to fire immediately after the fifth pass)
    var ci = setTimeout(ClearAllIntervals, 7050);

    // Perpetual check and removal every 2.5 seconds - The Peter Gabriel Sledgehammer Special
    if (arrayAbnormalBlockerDomains.indexOf(window.location.hostname) > -1) { var ABStatus = setInterval(SledgehammerRemoval, 2500); }


    console.clear();
}

// Load jQuery and then execute the main function
addJQuery(main);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址