Greasy Fork

Greasy Fork is available in English.

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

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

当前为 2025-04-29 提交的版本,查看 最新版本

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

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

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴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);
    }
})();