Anti [ AdBlock Detector ]

Today I saw a window asking me to disable AdBlock ._. If you also have a problem with this, then you can use this script

目前为 2022-11-08 提交的版本。查看 最新版本

// ==UserScript==
// @name        Anti [ AdBlock Detector ]
// @namespace   -
// @version     0.2
// @description Today I saw a window asking me to disable AdBlock ._. If you also have a problem with this, then you can use this script
// @author      Nudo#3310
// @match       *://moomoo.io/*
// @match       *://*.moomoo.io/*
// @icon        https://moomoo.io/img/favicon.png?v=1
// @run-at      document-start
// @grant       none
// ==/UserScript==

(function() {
    const detected = {
        active: false,
        element: null
    }

    const observer = new MutationObserver(function(mutations) {
        for (const mutation of mutations) {
            for (const node of mutation.addedNodes) {
                if (!node.classList) {
                    continue
                }

                let allElements = Object.values(document.querySelectorAll("*"))

                allElements = allElements.filter((element) => element.classList.value.length && element.tagName === "DIV")

                for (const element of allElements) {
                    if (!element.textContent.match(/Support\sFree\s\w+/)) {
                        continue
                    }

                    detected.active = true
                    detected.element = element

                    observer.disconnect()

                    break
                }
            }
        }
    })

    const interval = setInterval(() => {
        if (!detected.active) return void 0

        if (detected.element.style.visibility === "hidden") return void 0

        detected.element.remove()

        console.log("Anti [ AdBlock Detector ]::success", detected.element)

        clearInterval(interval)
    })

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