Greasy Fork

来自缓存

Greasy Fork is available in English.

屏蔽萌娘百科移动端APP打开提示

屏蔽萌娘百科移动端APP打开提示,直接删除###moe-open-in-app元素

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         屏蔽萌娘百科移动端APP打开提示
// @namespace    http://greasyfork.icu/
// @version      1.1.1
// @description  屏蔽萌娘百科移动端APP打开提示,直接删除###moe-open-in-app元素
// @author       迪普希克
// @license      MIT
// @match        *://moegirl.*.*/*
// @match        *://moegirl.*/*
// @match        *://*.moegirl.*.*/*
// @match        *://*.moegirl.*/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    const TARGET_ID = 'moe-open-in-app';
    const CHECK_INTERVAL = 10000; // 10秒

    function nuclearOption() {
        const target = document.getElementById(TARGET_ID);
        if (target) {
            // 彻底删除元素而非隐藏
            target.parentNode.removeChild(target);
            console.log('检测到弹窗元素,已永久移除');
        }
    }

    // 增强型监控系统
    function initObserver() {
        new MutationObserver((mutations) => {
            mutations.forEach((mutation) => {
                if (!mutation.addedNodes) return;
                nuclearOption(); // 发现任何DOM变化立即检查
            });
        }).observe(document.documentElement, {
            childList: true,
            subtree: true,
            attributes: true
        });
    }

    // 立即执行 + 定时器双重保障
    window.addEventListener('DOMContentLoaded', () => {
        // 首次核打击
        nuclearOption();
        
        // 定时复查
        const safetyCheck = setInterval(nuclearOption, CHECK_INTERVAL);
        
        // 页面卸载时清理定时器
        window.addEventListener('unload', () => {
            clearInterval(safetyCheck);
        });

        // 启动DOM监视
        initObserver();
    });

    // 针对SPA的额外防护
    if (window.history && window.history.pushState) {
        const originalPushState = history.pushState;
        history.pushState = function() {
            originalPushState.apply(this, arguments);
            nuclearOption();
        };

        window.addEventListener('popstate', nuclearOption);
    }
})();