MooMoo Performance Menu

FPS Booster For PC low-end By Zama (Not Hack! :D)

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         MooMoo Performance Menu
// @namespace    moomoo.optimizer
// @version      2.1
// @description  FPS Booster For PC low-end By Zama (Not Hack! :D)
// @author       Zama
// @match        *://moomoo.io/*
// @match        *://*.moomoo.io/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    const STORAGE_KEY = "moomoo_performance_settings";

    let settings = JSON.parse(
        localStorage.getItem(STORAGE_KEY) ||
        '{"optimizer":true,"fps":true,"video":true,"ultra":false,"night":false}'
    );

    let styleTag = null;
    let nightOverlay = null;

    function saveSettings() {
        localStorage.setItem(STORAGE_KEY, JSON.stringify(settings));
    }

    function applyOptimizer() {

        if (styleTag) styleTag.remove();

        styleTag = document.createElement("style");

        let css = "";

        if (settings.optimizer) {
            css += `
                *,
                *::before,
                *::after{
                    animation:none!important;
                    transition:none!important;
                    box-shadow:none!important;
                    text-shadow:none!important;
                }
            `;
        }

        if (settings.fps) {
            css += `
                canvas{
                    image-rendering:pixelated!important;
                }
            `;
        }

        if (settings.ultra) {
            css += `
                *{
                    filter:none!important;
                    backdrop-filter:none!important;
                }
            `;
        }

        styleTag.textContent = css;
        document.head.appendChild(styleTag);

        if (settings.video) {
            document.querySelectorAll("video").forEach(v => {
                v.style.display = "none";
            });
        }

        if (settings.ultra) {
            document.querySelectorAll("iframe").forEach(i => {
                i.style.display = "none";
            });
        }

        // NIGHT MODE
        if (settings.night) {

            if (!nightOverlay) {

                nightOverlay = document.createElement("div");

                Object.assign(nightOverlay.style, {
                    position: "fixed",
                    inset: "0",
                    background: "rgba(0,0,0,0.25)",
                    pointerEvents: "none",
                    zIndex: "999998"
                });

                document.body.appendChild(nightOverlay);
            }

        } else {

            if (nightOverlay) {
                nightOverlay.remove();
                nightOverlay = null;
            }
        }

        console.log("Optimizer Updated", settings);
    }

    applyOptimizer();

    const menu = document.createElement("div");

    Object.assign(menu.style, {
        position: "fixed",
        top: "60px",
        right: "10px",
        width: "250px",
        background: "rgba(0,0,0,0.85)",
        color: "white",
        padding: "10px",
        borderRadius: "8px",
        zIndex: "999999",
        fontFamily: "Arial",
        display: "none"
    });

    document.body.appendChild(menu);

    function createToggle(label, key) {

        const row = document.createElement("div");
        row.style.marginBottom = "8px";

        const checkbox = document.createElement("input");
        checkbox.type = "checkbox";
        checkbox.checked = settings[key];

        checkbox.addEventListener("change", () => {
            settings[key] = checkbox.checked;
            saveSettings();
            applyOptimizer();
        });

        row.appendChild(checkbox);

        const text = document.createElement("span");
        text.textContent = " " + label;

        row.appendChild(text);

        return row;
    }

    const title = document.createElement("h3");
    title.textContent = "Performance Menu By Zama";
    title.style.marginTop = "0";

    menu.appendChild(title);

    menu.appendChild(createToggle("Optimizer", "optimizer"));
    menu.appendChild(createToggle("FPS Stabilizer", "fps"));
    menu.appendChild(createToggle("Hide Videos", "video"));
    menu.appendChild(createToggle("Ultra Low Mode", "ultra"));
    menu.appendChild(createToggle("Night Mode", "night"));

    const info = document.createElement("div");
    info.style.marginTop = "10px";
    info.innerHTML = "Press ESC For Open/Close Menu";
    menu.appendChild(info);

    document.addEventListener("keydown", (e) => {

        if (e.key === "Escape") {

            menu.style.display =
                menu.style.display === "none"
                    ? "block"
                    : "none";
        }
    });

    const fpsBox = document.createElement("div");

    Object.assign(fpsBox.style, {
        position: "fixed",
        top: "10px",
        right: "10px",
        background: "rgba(0,0,0,0.8)",
        color: "lime",
        padding: "5px 10px",
        borderRadius: "6px",
        zIndex: "999999",
        fontFamily: "monospace"
    });

    document.body.appendChild(fpsBox);

    let last = performance.now();
    let frames = 0;

    function fpsLoop(now) {

        frames++;

        if (now - last >= 1000) {
            fpsBox.textContent = `FPS: ${frames}`;
            frames = 0;
            last = now;
        }

        requestAnimationFrame(fpsLoop);
    }

    requestAnimationFrame(fpsLoop);

})();