BlockBlockAdBlock

Blocks BlockAdBlock scripts. Toggleable if required.

目前為 2018-11-05 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        BlockBlockAdBlock
// @namespace   ZOWEB
// @version     2
// @description Blocks BlockAdBlock scripts. Toggleable if required.
// @match       *://*/*
// @run-at      document-start
// @license     MIT
// @noframes
// ==/UserScript==

function addFunction(func, exec) {
    // wait for document.head
    const int = setInterval(() => {
        if (!document.head) return;

        console.debug("Inserting script.");
        const script = document.createElement("script");
        script.textContent = "-" + func + (exec ? "()" : "");
        document.head.appendChild(script);
        setTimeout(script.remove.bind(script), 0);

        clearInterval(int);
    }, 0);
}

addFunction(function() {
    let hasEvaled = false, firstEvalId, firstEvalCode;

    const oldEval = window.eval;

    window.eval = d => {
        const id = Math.floor(Math.random() * 20), runChecker = Math.floor(Math.random() * 255).toString(16);

        hasEvaled = true;

        function b(checker) {
            if (checker === runChecker) {
                console.warn("bbab * Running eval script!");
                oldEval(d);
            } else console.error("bbab * Invalid checker! Eval will only run with the checker specified.");
        }

        if (localStorage.getItem("bbab") !== "disable") {
            console.warn("     * ---- * --- * --- * ---- *");
            console.warn("bbab * Eval script was blocked *");
            console.warn("bbab * From:", (new Error()).stack.split("\n")[1]);
            console.warn("bbab *  [ To run this script, type the following into the console: ]");
            console.warn("bbab *  [   window._bbab_" + id + "(\"" + runChecker + "\") ]");
          	console.warn("bbab *  [ To print this script, type the following into the console: ]");
          	console.warn("bbab *  [   window._bbab_p_" + id + " ]");
            window["_bbab_" + id] = a => b(a);
          	window["_bbab_p_" + id] = d;
        } else {
            console.warn("bbab * Letting through eval script as we are disabled.");
            oldEval(d);
        }

        if (typeof firstEvalId === "undefined") {
            firstEvalId = id;
            firstEvalCode = runChecker;
        }
    };

    // if we've visited this page multiple times add a popup to say so
    if (localStorage.getItem("bbab.visited") === "yes") {
        const elem = document.createElement("p");
        elem.id = "BBAB_POPUP";
        elem.style.position = "fixed";
        elem.style.bottom = ".5em";
        elem.style.right = ".5em";
        elem.style.padding = "1em";
        elem.style.backgroundColor = "#314159";
        elem.style.color = "#eff4ff";
        elem.style.borderRadius = "3px";
        elem.style.fontFamily = "sans-serif";
        elem.style.fontSize = "16px";
        elem.style.zIndex = "999999";

        const href = document.createElement("a");
        href.href = "#";
        href.style.color = "#99a9e6";
        href.style.textDecoration = "underline";

        const reloadLink = document.createElement("a");
        reloadLink.href = "#";
        reloadLink.style.color = "#99a9e6";
        reloadLink.style.textDecoration = "underline";
        reloadLink.textContent = "Reload to update";
        reloadLink.onclick = location.reload.bind(location, true);

        if (localStorage.getItem("bbab") !== "disable") {
            elem.textContent = "Disabling your adblocker on pages you visit frequently will help them survive. ";
            href.textContent = "Turn off BlockBlockAdBlock";

            href.addEventListener("click", e => {
                e.preventDefault();

                localStorage.setItem("bbab", "disable");

                elem.remove();
                window["_bbab_" + firstEvalId](firstEvalCode);
            });
        } else {
            elem.textContent = "Want to re-enable your adblocker? ";
            href.textContent = "Turn on BlockBlockAdBlock";

            href.addEventListener("click", e => {
                e.preventDefault();

                localStorage.setItem("bbab", "enable");

                elem.textContent = "";
                elem.appendChild(reloadLink);
            });
        }

        elem.appendChild(href);

        setTimeout(() => {
            console.debug("Checking if we've been blocked");
            if (hasEvaled) {
                console.debug("Inserting elem");
                document.body.appendChild(elem)
            }
            }, 3000);
    }
    localStorage.setItem("bbab.visited", "yes")
}, true);

console.info("You are being protected.");