SwordMasters.io - Custom UI Panel

Panel kéo được + On/Off + Slider (UI only, safe)

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         SwordMasters.io - Custom UI Panel
// @namespace    https://greasyfork.org/
// @version      2.0
// @description  Panel kéo được + On/Off + Slider (UI only, safe)
// @match        https://swordmasters.io/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let value = 50;
    let isEnabled = false;

    const panel = document.createElement('div');
    panel.style.cssText = `
        position: fixed; left: 30px; top: 30px; z-index: 999999;
        background: rgba(0,0,0,0.85); color: white; padding: 15px;
        border-radius: 12px; font-family: Arial; width: 250px;
    `;

    panel.innerHTML = `
        <div style="font-weight:bold; margin-bottom:10px;">⚔️ Custom Panel</div>
        <div id="status">OFF</div>

        <input type="range" id="slider" min="1" max="100" value="${value}">
        <div>Value: <span id="val">${value}</span></div>

        <button id="btn">BẬT</button>
    `;

    document.body.appendChild(panel);

    const slider = panel.querySelector('#slider');
    const val = panel.querySelector('#val');
    const btn = panel.querySelector('#btn');
    const status = panel.querySelector('#status');

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

    btn.onclick = () => {
        isEnabled = !isEnabled;
        status.textContent = isEnabled ? "ON" : "OFF";
    };

    // drag
    let drag = false, x, y;

    panel.onmousedown = (e) => {
        drag = true;
        x = e.clientX - panel.offsetLeft;
        y = e.clientY - panel.offsetTop;
    };

    document.onmousemove = (e) => {
        if (drag) {
            panel.style.left = (e.clientX - x) + "px";
            panel.style.top = (e.clientY - y) + "px";
        }
    };

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

})();