Sword Master Upgrade Control ⚒️

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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.

(I already have a user style manager, let me install it!)

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

})();