Greasy Fork

Greasy Fork is available in English.

Alert弹窗拦截

某些网站会弹出alert弹窗很烦人,可以直接拦截输出到控制台

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Alert弹窗拦截
// @namespace    https://www.aoaostar.com
// @version      0.1
// @description  某些网站会弹出alert弹窗很烦人,可以直接拦截输出到控制台
// @author       Pluto
// @license      GPL3.0
// @match        *://*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=www.aoaostar.com
// @grant        unsafeWindow
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_notification
// @grant        GM_registerMenuCommand
// @grant        GM_openInTab

// @run-at document-start
// ==/UserScript==


(function() {
    'use strict';
    if(contain_platform()){
        unsafeWindow.alert = function(e){
            console.log(e)
        }
    }

    const MenuCommands = [
        {
            title: `${!contain_platform() ? '🍀 添加' : '🍁 删除'}网站`,
            func: function () {
                const b = contain_platform();
                let platforms_data = new Set(GM_getValue('platforms_data', []))
                !b ? platforms_data.add(document.domain) : platforms_data.delete(document.domain)
                GM_setValue('platforms_data', [...platforms_data])
                notification(`${b ? '删除' : '添加'}网站成功`)
                location.reload()
            }
        },
        {
            title: "💬 反馈 & 建议 [Github]",
            func: function () {
                GM_openInTab("https://github.com/aoaostar/cdn/issues")
            }
        },
    ]
    register_menu_command()

    function register_menu_command() {
        for (const command of MenuCommands) {
            GM_registerMenuCommand(command.title, command.func)
        }
    }

    function contain_platform() {
        return new Set(GM_getValue('platforms_data', [])).has(document.domain)
    }

    function notification(message) {
        GM_notification({
            text: message,
            timeout: 4000,
        })
    }

})();