Greasy Fork

Greasy Fork is available in English.

小黑盒互动地图app广告自动隐藏

通过点击实现自动隐藏小黑盒互动地图app广告

当前为 2024-08-24 提交的版本,查看 最新版本

// ==UserScript==
// @name         小黑盒互动地图app广告自动隐藏
// @namespace    http://tampermonkey.net/
// @version      1.1
// @license      MIT
// @description  通过点击实现自动隐藏小黑盒互动地图app广告
// @author       NoWorld
// @match        https://web.xiaoheihe.cn/tools/map?game_name=*&zoom=8
// @icon         https://web.xiaoheihe.cn/public/heybox_bbs_128_128.png
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 点击实现
    function clickElements(selector) {
        const elements = document.querySelectorAll(selector);
        elements.forEach((element) => {
            if (element) {
                element.click();
            }
        });
    }
    // 点击按钮
    const observer = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
            if (mutation.addedNodes.length) {
                clickElements('div.btn');
            }
        });
    });

    // 加载内容
    observer.observe(document.body, { childList: true, subtree: true });
})();