Anti-Anti Adblock v1 (All Sites)

A simple anti-adblock script, will work for typical anti-adblock stuff rolled out by Google.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name           Anti-Anti Adblock v1 (All Sites)
// @namespace      https://greasyfork.org/en/users/198860-zyenith
// @grant          none
// @description    A simple anti-adblock script, will work for typical anti-adblock stuff rolled out by Google.
// @author         zyenith
// @version        0.0.1
// @match          *://*/*
// @run-at         document-start
// @antifeature    Tracking, for compatibility info
// @require        https://greasyfork.org/scripts/410512-sci-js-from-ksw2-center/code/scijs%20(from%20ksw2-center).js
// ==/UserScript==

const detected = {
    active: false,
    element: null
};

const observer = new MutationObserver((mutations) => {
    mutations.forEach((mutation) => {
        mutation.addedNodes.forEach((node) => {
            if (!node.classList) {
                return;
            }

            const allElements = document.getElementsByTagName("*");

            const element = Array.from(allElements).find((element) => element.classList.value.length && element.tagName === "DIV" && element.textContent.match(/Support\sFree\s\w+/));

            if (!element) {
                return;
            }

            detected.active = true;
            detected.element = element;

            observer.disconnect();

            const visibilityObserver = new MutationObserver((mutations) => {
                mutations.forEach((mutation) => {
                    if (mutation.target.style.visibility === "hidden") {
                        element.remove();
                        visibilityObserver.disconnect();
                    };
                });
            });

            visibilityObserver.observe(element, { attributes: true });
        });
    });
});

observer.observe(document, { childList: true, subtree: true });

setTimeout(observer.disconnect, 25000);