Sword Master Upgrade Control ⚒️

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

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

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

})();