Greasy Fork

Greasy Fork is available in English.

萌娘百科去除烦人的 adblock 检测弹窗

去除烦人的 adblock 检测弹窗

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         萌娘百科去除烦人的 adblock 检测弹窗
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  去除烦人的 adblock 检测弹窗
// @author       https://github.com/yuzhanglong
// @match        https://zh.moegirl.org.cn/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=moegirl.org.cn
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
  const mutationObserver = new MutationObserver((mutationsList) => {
    for (const mutation of mutationsList) {
      if (mutation.type === 'childList') {
        const adblockDialog = [...mutation.addedNodes].find((node) => {
          return node.className === 'fc-ab-root';
        });

        if (adblockDialog) {
          if (adblockDialog.innerHTML.includes('白名单')) {
            const closeButton = adblockDialog.getElementsByClassName('fc-close')[0];
            if (closeButton) {
              closeButton.click();
            }
          }
        }
      }
    }
  });

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