Kour.io 模組選單2

模組選單

// ==UserScript==
// @name        Kour.io 模組選單2
// @match       *://kour.io/*
// @grant       none
// @version     1.2
// @author      HUANG WEI-LUN HUANG WEI-LUN
// @description 模組選單
// @namespace http://tampermonkey.net/
// ==/UserScript==
(function () {
    console.clear();
    console.log("🛠️ Kour.io 模組選單(含自訂熱鍵)載入");

    if (document.getElementById("modMenu")) return;

    const features = [
        { name: "🎯 Aimbot", key: "aimbot", enabled: false },
        { name: "👁️ Wallhack", key: "wallhack", enabled: false },
        { name: "🏃 Speed Hack", key: "speed", enabled: false },
        { name: "🔫 Auto Shoot", key: "autoshoot", enabled: false }
    ];

    // 🧩 取得目前熱鍵(預設 M)
    const hotkeyStorageKey = "modMenuHotkey";
    let toggleKey = localStorage.getItem(hotkeyStorageKey) || "m";

    const modMenu = document.createElement("div");
    modMenu.id = "modMenu";
    modMenu.style.position = "fixed";
    modMenu.style.top = "80px";
    modMenu.style.right = "20px";
    modMenu.style.width = "220px";
    modMenu.style.background = "rgba(0, 0, 0, 0.85)";
    modMenu.style.border = "1px solid lime";
    modMenu.style.color = "#0f0";
    modMenu.style.padding = "12px";
    modMenu.style.borderRadius = "8px";
    modMenu.style.fontFamily = "monospace";
    modMenu.style.zIndex = 9999;
    modMenu.innerHTML = `<h3 style="margin-top:0;">⚙️ 模組選單</h3>`;
    document.body.appendChild(modMenu);

    // 顯示當前熱鍵
    const hotkeyDisplay = document.createElement("div");
    hotkeyDisplay.innerHTML = `當前熱鍵:<b>${toggleKey.toUpperCase()}</b>`;
    hotkeyDisplay.style.marginBottom = "10px";
    modMenu.appendChild(hotkeyDisplay);

    // 建立模組按鈕
    features.forEach((mod) => {
        const btn = document.createElement("button");
        btn.textContent = `[OFF] ${mod.name}`;
        btn.style.width = "100%";
        btn.style.margin = "4px 0";
        btn.style.padding = "6px";
        btn.style.background = "#111";
        btn.style.border = "1px solid #0f0";
        btn.style.color = "#0f0";
        btn.style.cursor = "pointer";
        btn.onclick = () => {
            mod.enabled = !mod.enabled;
            btn.textContent = `${mod.enabled ? "[ON] ✅" : "[OFF] ❌"} ${mod.name}`;
            console.log(`${mod.name} 已${mod.enabled ? "啟用 ✅" : "關閉 ❌"}(模擬)`);
        };
        modMenu.appendChild(btn);
    });

    // 🔄 變更熱鍵按鈕
    const changeKeyBtn = document.createElement("button");
    changeKeyBtn.textContent = "🔧 更改熱鍵";
    changeKeyBtn.style.marginTop = "10px";
    changeKeyBtn.style.width = "100%";
    changeKeyBtn.style.padding = "6px";
    changeKeyBtn.style.background = "#222";
    changeKeyBtn.style.border = "1px solid #0f0";
    changeKeyBtn.style.color = "#0f0";
    changeKeyBtn.style.cursor = "pointer";
    modMenu.appendChild(changeKeyBtn);

    changeKeyBtn.onclick = () => {
        const input = prompt("請輸入新的熱鍵(單一字母鍵,例如:M、P、Z):");
        if (input && input.length === 1 && /^[a-zA-Z]$/.test(input)) {
            toggleKey = input.toLowerCase();
            localStorage.setItem(hotkeyStorageKey, toggleKey);
            hotkeyDisplay.innerHTML = `當前熱鍵:<b>${toggleKey.toUpperCase()}</b>`;
            alert(`✅ 熱鍵已設為 ${toggleKey.toUpperCase()}`);
        } else {
            alert("❌ 請輸入一個有效的單一字母鍵");
        }
    };

    // ⌨️ 監聽熱鍵切換模組選單
    let visible = true;
    document.addEventListener("keydown", (e) => {
        if (e.key.toLowerCase() === toggleKey) {
            visible = !visible;
            modMenu.style.display = visible ? "block" : "none";
            console.log(visible ? "🟢 模組選單顯示" : "🔴 模組選單隱藏");
        }
    });
})();