Sword Master Upgrade Control ⚒️

Điều chỉnh % nâng cấp (UI + toggle + kéo thả)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Sword Master Upgrade Control ⚒️
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Điều chỉnh % nâng cấp (UI + toggle + kéo thả)
// @match        *://swordmaster.io/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    let enabled = false;
    let percent = 50;

    // ===== UI =====
    const box = document.createElement("div");
    box.innerHTML = `
        <div id="hackBox">
            <div id="header">⚒️ Dwarf Upgrade <span id="drag">[Kéo]</span></div>
            <div>ON/OFF: <button id="toggle">OFF</button></div>
            <div>%: <span id="value">50</span>%</div>
            <input type="range" min="1" max="100" value="50" id="slider">
            <div>
                <button id="minus">-</button>
                <button id="plus">+</button>
            </div>
        </div>
    `;
    document.body.appendChild(box);

    const style = document.createElement("style");
    style.innerHTML = `
        #hackBox {
            position: fixed;
            top: 100px;
            left: 100px;
            width: 160px;
            background: rgba(0,0,0,0.8);
            color: white;
            padding: 10px;
            border-radius: 10px;
            font-size: 13px;
            z-index: 9999;
        }
        #header {
            font-weight: bold;
            margin-bottom: 5px;
        }
        button {
            margin: 2px;
        }
        input {
            width: 100%;
        }
    `;
    document.head.appendChild(style);

    // ===== Control =====
    const toggleBtn = document.getElementById("toggle");
    const slider = document.getElementById("slider");
    const valueText = document.getElementById("value");

    toggleBtn.onclick = () => {
        enabled = !enabled;
        toggleBtn.textContent = enabled ? "ON" : "OFF";
    };

    slider.oninput = () => {
        percent = slider.value;
        valueText.textContent = percent;
    };

    document.getElementById("minus").onclick = () => {
        percent = Math.max(1, percent - 1);
        slider.value = percent;
        valueText.textContent = percent;
    };

    document.getElementById("plus").onclick = () => {
        percent = Math.min(100, percent + 1);
        slider.value = percent;
        valueText.textContent = percent;
    };

    // ===== Drag =====
    let isDragging = false, offsetX, offsetY;

    box.onmousedown = (e) => {
        isDragging = true;
        offsetX = e.clientX - box.offsetLeft;
        offsetY = e.clientY - box.offsetTop;
    };

    document.onmousemove = (e) => {
        if (isDragging) {
            box.style.left = (e.clientX - offsetX) + "px";
            box.style.top = (e.clientY - offsetY) + "px";
        }
    };

    document.onmouseup = () => isDragging = false;

    // ===== Hook thử nâng cấp =====
    // (Chỉ hoạt động nếu game xử lý phía client)
    const originalRandom = Math.random;

    Math.random = function () {
        if (enabled) {
            return percent / 100;
        }
        return originalRandom();
    };

})();