Sword Master Upgrade Control ⚒️

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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();
    };

})();