Sword Master Upgrade Control ⚒️

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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

})();