Toggle Labyrinth Ping

Adds a menu button to toggle the 'Labryinth Ping' badge.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Toggle Labyrinth Ping
// @namespace    https://www.milkywayidle.com/
// @version      1.2
// @description  Adds a menu button to toggle the 'Labryinth Ping' badge.
// @author       SilkyPanda
// @match        *://www.milkywayidle.com/*
// @match        *://milkywayidle.com/*
// @match        https://test.milkywayidle.com/*
// @icon         https://www.milkywayidle.com/favicon.svg
// @grant        GM_registerMenuCommand
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_addStyle
// @license      MIT
// ==/UserScript==


(function() {
    'use strict';

    let isDisabled = GM_getValue("disableLabyrinthPing", true);
    const styleId = "labyrinth-ping-remover-style";

    // CSS Logic: specifically targets the Labyrinth bar using the aria-label from the SVG
    const updateCSS = () => {
        let styleElement = document.getElementById(styleId);
        if (isDisabled) {
            if (!styleElement) {
                const style = document.createElement('style');
                style.id = styleId;

                style.innerHTML = `
                    .NavigationBar_nav__3uuUl:has(svg[aria-label="navigationBar.labyrinth"]) .NavigationBar_badge__3I_xZ {
                        display: none !important;
                    }
                `;
                document.head.appendChild(style);
            }
        } else {
            if (styleElement) {
                styleElement.remove();
            }
        }
    };

    GM_registerMenuCommand("Toggle Disable Labyrinth Ping", () => {
        isDisabled = !isDisabled;
        GM_setValue("disableLabyrinthPing", isDisabled);

        updateCSS();

    });

    updateCSS();

})();