Macro Menu (Right Shift + R Toggle)

UI-only macro menu with Right Shift and R toggle

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Macro Menu (Right Shift + R Toggle)
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  UI-only macro menu with Right Shift and R toggle
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    // -----------------------------
    // Create Menu
    // -----------------------------
    const menu = document.createElement("div");
    menu.id = "macroMenu";
    menu.innerHTML = `
        <h2>Macro Menu</h2>
        <p>Status: <span id="featureStatus" style="color:#ff4444;">OFF</span></p>
        <p>Press <b>R</b> to toggle feature</p>
    `;
    document.body.appendChild(menu);

    // -----------------------------
    // Style
    // -----------------------------
    const style = document.createElement("style");
    style.textContent = `
        #macroMenu {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%) scale(0.8);
            background: rgba(20, 20, 20, 0.92);
            padding: 20px;
            border-radius: 12px;
            color: white;
            font-family: Arial, sans-serif;
            z-index: 999999999;
            display: none;
            width: 260px;
            text-align: center;
            transition: 0.15s ease;
            border: 1px solid #444;
            box-shadow: 0 0 20px rgba(0,0,0,0.4);
        }

        #macroMenu.open {
            display: block;
            transform: translate(-50%, -50%) scale(1);
        }

        #macroMenu h2 {
            margin-top: 0;
            color: #7ab6ff;
        }
    `;
    document.head.appendChild(style);

    // -----------------------------
    // Logic
    // -----------------------------
    let menuOpen = false;
    let featureEnabled = false;

    // Toggle menu with Right Shift
    window.addEventListener("keydown", (e) => {
        if (e.code === "ShiftRight") {
            menuOpen = !menuOpen;
            menu.classList.toggle("open", menuOpen);
        }
    });

    // Toggle feature with R
    window.addEventListener("keydown", (e) => {
        if (e.code === "KeyR") {
            featureEnabled = !featureEnabled;
            document.getElementById("featureStatus").textContent = featureEnabled ? "ON" : "OFF";
            document.getElementById("featureStatus").style.color = featureEnabled ? "#44ff44" : "#ff4444";

            // 🔧 This is where YOU add whatever you want the toggle to do
            // Example: console.log("Feature is now", featureEnabled);
        }
    });

})();