UI MASTER

A Bloxd.io custom client.

// ==UserScript==
// @name         UI MASTER
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  A Bloxd.io custom client.
// @author       my_name_chinese
// @match        http://staging.bloxd.io/
// @match        https://bloxd.io/
// @icon         https://imgur.com/NLAKmI9.png
// @grant        none
// @license      GPLv3
// ==/UserScript==

(function() {
    'use strict';


    // Define Main Menu
    let clientMainMenu;
    clientMainMenu = document.createElement("div");
    clientMainMenu.textContent = "UI MASTER";
    clientMainMenu.style.position = "fixed";
    clientMainMenu.style.color = "#1B4F72";
    clientMainMenu.style.textShadow = "3px 3px 4px white";
    clientMainMenu.style.top = "50%";
    clientMainMenu.style.left = "50%";
    clientMainMenu.style.transform = "translate(-50%, -50%)";
    clientMainMenu.style.zIndex = "10000";
    clientMainMenu.style.borderRadius = "10px";
    clientMainMenu.style.backgroundImage = "url(https://i.postimg.cc/9FxdHSZc/NLAKmI9.png)";
    clientMainMenu.style.backgroundRepeat = "no-repeat";
    clientMainMenu.style.backgroundSize = "cover";
    clientMainMenu.style.backgroundPosition = "center";
    clientMainMenu.style.boxShadow = "0px 0px 20px rgba(0, 0, 0, 0.5)";
    clientMainMenu.style.fontSize = "24px";
    clientMainMenu.style.height = "600px";
    clientMainMenu.style.width = "500px";
    clientMainMenu.style.textAlign = "center";
    clientMainMenu.style.lineHeight = "50px";
    clientMainMenu.style.visibility = "hidden";
    clientMainMenu.style.opacity = "99%";
    clientMainMenu.style.userSelect = "none";


    let bindMainMenu;
    bindMainMenu = document.createElement("div");
    bindMainMenu.style.position = "fixed";
    bindMainMenu.style.backgroundcolor = "#2E86C1"
    bindMainMenu.style.opacity = '0.1';
    bindMainMenu.style.color = "#1B4F72";
    bindMainMenu.style.textShadow = "3px 3px 4px white";
    bindMainMenu.style.top = "50%";
    bindMainMenu.style.left = "50%";
    bindMainMenu.style.transform = "translate(-50%, -50%)";
    bindMainMenu.style.zIndex = "10000";
    bindMainMenu.style.borderRadius = "10px";
    bindMainMenu.style.backgroundRepeat = "no-repeat";
    bindMainMenu.style.backgroundSize = "cover";
    bindMainMenu.style.backgroundPosition = "center";
    bindMainMenu.style.fontSize = "24px";
    bindMainMenu.style.height = "300px";
    bindMainMenu.style.width = "400px";
    bindMainMenu.style.textAlign = "center";
    bindMainMenu.style.lineHeight = "50px";
    bindMainMenu.style.visibility = "hidden";
    bindMainMenu.style.opacity = "99%";
    bindMainMenu.style.userSelect = "none";


    // Define Button Elements
    let wkey;
    wkey = document.createElement('div');
    wkey.style.position = "relative";
    wkey.style.color = "#ffffff";
    wkey.textContent = "W";
    wkey.style.top = "-5px";
    wkey.style.left = "160px";
    wkey.style.zIndex = "10000";
    wkey.style.fontWeight = "bold";
    wkey.style.borderRadius = "10px";
    wkey.style.backgroundColor = "#66ccff";
    wkey.style.fontSize = "24px";
    wkey.style.height = "50px";
    wkey.style.width = "50px";
    wkey.style.textAlign = "center";
    wkey.style.lineHeight = "50px";
    wkey.style.filter = "blur(1px)";
    bindMainMenu.appendChild(wkey);


    let skey;
    skey = document.createElement('div');
    skey.style.position = "relative";
    skey.style.color = "#ffffff";
    skey.textContent = "S";
    skey.style.top = "0px";
    skey.style.left = "50%";
    skey.style.transform = "translateX(-50%)";
    skey.style.zIndex = "10000";
    skey.style.fontWeight = "bold";
    skey.style.borderRadius = "10px";
    skey.style.backgroundColor = "#66ccff";
    skey.style.fontSize = "24px";
    skey.style.height = "50px";
    skey.style.width = "50px";
    skey.style.textAlign = "center";
    skey.style.lineHeight = "50px";
    skey.style.filter = "blur(1px)";
    bindMainMenu.appendChild(skey);

    let akey;
    akey = document.createElement('div');
    akey.style.position = "relative";
    akey.style.color = "#ffffff";
    akey.textContent = "A";
    akey.style.top = "-50px";
    akey.style.left = "140px";
    akey.style.transform = "translateX(-50%)";
    akey.style.zIndex = "10000";
    akey.style.fontWeight = "bold";
    akey.style.borderRadius = "10px";
    akey.style.backgroundColor = "#66ccff";
    akey.style.fontSize = "24px";
    akey.style.height = "50px";
    akey.style.width = "50px";
    akey.style.textAlign = "center";
    akey.style.lineHeight = "50px";
    akey.style.filter = "blur(1px)";
    bindMainMenu.appendChild(akey);

    let dkey;
    dkey = document.createElement('div');
    dkey.style.position = "relative";
    dkey.style.color = "#ffffff";
    dkey.textContent = "D";
    dkey.style.top = "-100px";
    dkey.style.left = "260px";
    dkey.style.transform = "translateX(-50%)";
    dkey.style.zIndex = "10000";
    dkey.style.fontWeight = "bold";
    dkey.style.borderRadius = "10px";
    dkey.style.backgroundColor = "#66ccff";
    dkey.style.fontSize = "24px";
    dkey.style.height = "50px";
    dkey.style.width = "50px";
    dkey.style.textAlign = "center";
    dkey.style.lineHeight = "50px";
    dkey.style.filter = "blur(1px)";
    bindMainMenu.appendChild(dkey);

    let lmb;
    lmb = document.createElement('div');
    lmb.style.position = "relative";
    lmb.style.color = "#ffffff";
    lmb.textContent = "LMB";
    lmb.style.top = "-90px";
    lmb.style.left = "140px";
    lmb.style.transform = "translateX(-50%)";
    lmb.style.zIndex = "10000";
    lmb.style.fontWeight = "bold";
    lmb.style.borderRadius = "10px";
    lmb.style.backgroundColor = "#66ccff";
    lmb.style.fontSize = "18px";
    lmb.style.height = "50px";
    lmb.style.width = "100px";
    lmb.style.textAlign = "center";
    lmb.style.lineHeight = "50px";
    lmb.style.filter = "blur(1px)";
    bindMainMenu.appendChild(lmb);

    let rmb;
    rmb = document.createElement('div');
    rmb.style.position = "relative";
    rmb.style.color = "#ffffff";
    rmb.textContent = "RMB";
    rmb.style.top = "-140px";
    rmb.style.left = "260px";
    rmb.style.transform = "translateX(-50%)";
    rmb.style.zIndex = "10000";
    rmb.style.fontWeight = "bold";
    rmb.style.borderRadius = "10px";
    rmb.style.backgroundColor = "#66ccff";
    rmb.style.fontSize = "18px";
    rmb.style.height = "50px";
    rmb.style.width = "100px";
    rmb.style.textAlign = "center";
    rmb.style.lineHeight = "50px";
    rmb.style.filter = "blur(1px)";
    bindMainMenu.appendChild(rmb);

    let space;
    space = document.createElement('div');
    space.style.position = "relative";
    space.style.color = "#ffffff";
    space.textContent = "SPACE";
    space.style.top = "-125px";
    space.style.left = "200px";
    space.style.transform = "translateX(-50%)";
    space.style.zIndex = "10000";
    space.style.fontWeight = "bold";
    space.style.borderRadius = "10px";
    space.style.backgroundColor = "#66ccff";
    space.style.fontSize = "18px";
    space.style.height = "50px";
    space.style.width = "220px";
    space.style.textAlign = "center";
    space.style.lineHeight = "50px";
    space.style.filter = "blur(1px)";
    bindMainMenu.appendChild(space);

    let shift;
    shift = document.createElement('div');
    shift.style.position = "relative";
    shift.style.color = "#ffffff";
    shift.textContent = "SHIFT";
    shift.style.top = "-240px";
    shift.style.left = "50px";
    shift.style.transform = "translateX(-50%)";
    shift.style.zIndex = "10000";
    shift.style.fontWeight = "bold";
    shift.style.borderRadius = "10px";
    shift.style.backgroundColor = "#66ccff";
    shift.style.fontSize = "18px";
    shift.style.height = "100px";
    shift.style.width = "50px";
    shift.style.textAlign = "center";
    shift.style.lineHeight = "100px";
    shift.style.filter = "blur(1px)";
    bindMainMenu.appendChild(shift);

    let caps;
    caps = document.createElement('div');
    caps.style.position = "relative";
    caps.style.color = "#ffffff";
    caps.textContent = "CAPS";
    caps.style.top = "-340px";
    caps.style.left = "350px";
    caps.style.transform = "translateX(-50%)";
    caps.style.zIndex = "10000";
    caps.style.fontWeight = "bold";
    caps.style.borderRadius = "10px";
    caps.style.backgroundColor = "#66ccff";
    caps.style.fontSize = "18px";
    caps.style.height = "100px";
    caps.style.width = "50px";
    caps.style.textAlign = "center";
    caps.style.lineHeight = "100px";
    caps.style.filter = "blur(1px)";
    bindMainMenu.appendChild(caps);


    // Add the elements to the body and the clientMainMenu
    document.body.appendChild(bindMainMenu);
    document.body.appendChild(clientMainMenu);

    // Add Event Listeners for the Keybinds

    document.addEventListener('keydown', function(event) {
        if (event.key === 'w') {
            wkey.style.backgroundColor = "#3366ff";
        }
        if (event.key === 's') {
            skey.style.backgroundColor = "#3366ff";
        }
        if (event.key === 'a') {
            akey.style.backgroundColor = "#3366ff";
        }
        if (event.key === 'd') {
            dkey.style.backgroundColor = "#3366ff";
        }
        if (event.key === ' ') {
            space.style.backgroundColor = "#3366ff";
        }
        if (event.key === 'Shift') {
            shift.style.backgroundColor = "#3366ff";
        }
        if (event.key === 'CapsLock') {
            caps.style.backgroundColor = "#3366ff";
        }
    });

    document.addEventListener('keyup', function(event) {
        if (event.key === 'w') {
            wkey.style.backgroundColor = "#66ccff";
        }
        if (event.key === 's') {
            skey.style.backgroundColor = "#66ccff";
        }
        if (event.key === 'a') {
            akey.style.backgroundColor = "#66ccff";
        }
        if (event.key === 'd') {
            dkey.style.backgroundColor = "#66ccff";
        }
        if (event.key === ' ') {
            space.style.backgroundColor = "#66ccff";
        }
        if (event.key === 'Shift') {
            shift.style.backgroundColor = "#66ccff";
        }
        if (event.key === 'CapsLock') {
            caps.style.backgroundColor = "#66ccff";
        }
    });

    document.addEventListener('mousedown', function(event) {
        if (event.button === 0) {
            lmb.style.backgroundColor = "#3366ff";
        }
        if (event.button === 2) {
            rmb.style.backgroundColor = "#3366ff";
        }
    });

    document.addEventListener('mouseup', function(event) {
        if (event.button === 0) {
            lmb.style.backgroundColor = "#66ccff";
        }
        if (event.button === 2) {
            rmb.style.backgroundColor = "#66ccff";
        }
    });

    // Define Main Menu dragging

    let mainisDragging = false;
    let offsetX = 0;
    let offsetY = 0;

    clientMainMenu.addEventListener('mousedown', function(event) {
        if (event.target.nodeName !== 'INPUT') {
            mainisDragging = true;
            offsetX = event.clientX;
            offsetY = event.clientY;
        }
    });

    document.addEventListener('mousemove', function(event) {
        if (mainisDragging) {
            const left = event.clientX;
            const top = event.clientY;

            clientMainMenu.style.left = left + "px";
            clientMainMenu.style.top = top + "px";
        }
    });

    document.addEventListener('mouseup', function() {
        mainisDragging = false;
    });

    let bindisDragging = false;
    let offsetX1 = 0;
    let offsetY1 = 0;

    bindMainMenu.addEventListener('mousedown', function(event) {
        if (event.target.nodeName !== 'INPUT') {
            bindisDragging = true;
            offsetX = event.clientX;
            offsetY = event.clientY;
        }
    });

    document.addEventListener('mousemove', function(event) {
        if (bindisDragging) {
            const left = event.clientX;
            const top = event.clientY;

            bindMainMenu.style.left = left + "px";
            bindMainMenu.style.top = top + "px";
        }
    });

    document.addEventListener('mouseup', function() {
        bindisDragging = false;
    });
    document.addEventListener('keydown', function(event) {
        if (event.key === 'U' || event.key === 'u') {
            clientMainMenu.style.visibility = clientMainMenu.style.visibility === "hidden" ? "visible" : "hidden";
        }
    });

    // Define imputs and main menu text

    let clientheader
    clientheader = document.createElement("div");
    clientheader.textContent = "Made By my_name_chinese";
    clientheader.style.position = "absolute";
    clientheader.style.top = "20px";
    clientheader.style.left = "50%";
    clientheader.style.transform = "translateX(-50%)";
    clientheader.style.fontSize = "15px";
    clientMainMenu.appendChild(clientheader);

    // Create the button element
    const bilibutton = document.createElement("div");
    bilibutton.style.position = "absolute";
    bilibutton.style.top = "60px";
    bilibutton.style.left = "50%";
    bilibutton.style.transform = "translateX(-50%)";
    bilibutton.style.cursor = "pointer";
    bilibutton.style.backgroundColor = "#66ccff";
    bilibutton.style.backgroundImage = "linear-gradient(to bottom, #2E86C1, #AED6F1)";
    bilibutton.style.color = "#1B4F72";
    bilibutton.style.borderRadius = "10px";
    bilibutton.style.height = "40px";
    bilibutton.style.padding = "8px";
    bilibutton.addEventListener("click", function() {
        window.location.href = "https://space.bilibili.com/3546388900088449?spm_id_from=333.1007.0.0";
    });

    // Create the text element
    const bilibuttonText = document.createElement("div");
    bilibuttonText.textContent = "my_name_bilibili_acc";
    bilibuttonText.style.fontSize = "20px";
    bilibuttonText.style.textAlign = "center";
    bilibuttonText.style.top = "50%";
    bilibuttonText.style.transform = "translateY(-25%)";

    // Append the text element to the button element
    bilibutton.appendChild(bilibuttonText);

    // Append the button element to the desired parent element
    clientMainMenu.appendChild(bilibutton);


    let clientsettingstext;
    clientsettingstext = document.createElement("div");
    clientsettingstext.textContent = "- Client Settings -";
    clientsettingstext.style.position = "absolute";
    clientsettingstext.style.color = "#1B4F72"
    clientsettingstext.style.top = "120px";
    clientsettingstext.style.left = "50%";
    clientsettingstext.style.transform = "translateX(-50%)";
    clientsettingstext.style.fontSize = "20px";
    clientMainMenu.appendChild(clientsettingstext);

    let clientsettingsinput
    clientsettingsinput = document.createElement("input");
    clientsettingsinput.type = "text";
    clientsettingsinput.placeholder = "Client Background URL";
    clientsettingsinput.style.backgroundColor = '#AED6F1';
    clientsettingsinput.style.border = '3px double #1B4F72';
    clientsettingsinput.style.position = "absolute";
    clientsettingsinput.style.top = "160px";
    clientsettingsinput.style.left = "50%";
    clientsettingsinput.style.transform = "translateX(-50%)";
    clientMainMenu.appendChild(clientsettingsinput);

    clientsettingsinput.addEventListener('input', function() {
        clientMainMenu.style.backgroundImage = `url(${clientsettingsinput.value})`;
    });

    clientsettingsinput.addEventListener('mousedown', function(event) {
        event.stopPropagation();
    });

    let hotbarsettingstext;
    hotbarsettingstext = document.createElement("div");
    hotbarsettingstext.textContent = "- HotBar Settings -";
    hotbarsettingstext.style.position = "absolute";
    hotbarsettingstext.style.top = "220px";
    hotbarsettingstext.style.left = "50%";
    hotbarsettingstext.style.transform = "translateX(-50%)";
    hotbarsettingstext.style.fontSize = "20px";
    clientMainMenu.appendChild(hotbarsettingstext);

    let hotbarmaincolorinput
    hotbarmaincolorinput = document.createElement("input");
    hotbarmaincolorinput.type = "color";
    hotbarmaincolorinput.value = "#3d4b79"
    hotbarmaincolorinput.style.top = "250px";
    hotbarmaincolorinput.style.marginTop = "15px";
    hotbarmaincolorinput.style.position = "absolute";
    hotbarmaincolorinput.style.left = "44%";
    hotbarmaincolorinput.style.transform = "translateX(-50%)";
    clientMainMenu.appendChild(hotbarmaincolorinput);

    hotbarmaincolorinput.addEventListener("input", function() {
        const color = hotbarmaincolorinput.value;
        hotbarmaincolorinput.value = color;
        const hotbars = document.querySelectorAll(".item");

        hotbars.forEach(function(hotbar) {
            hotbar.style.backgroundColor = color;
        });
    });

    let hotbarbordercolorinput;
    hotbarbordercolorinput = document.createElement("input");
    hotbarbordercolorinput.type = "color";
    hotbarbordercolorinput.style.top = "250px";
    hotbarbordercolorinput.value = "#303a59";
    hotbarbordercolorinput.style.marginTop = "15px";
    hotbarbordercolorinput.style.position = "absolute";
    hotbarbordercolorinput.style.left = "56%";
    hotbarbordercolorinput.style.transform = "translateX(-50%)";
    clientMainMenu.appendChild(hotbarbordercolorinput);

    hotbarbordercolorinput.addEventListener("input", function() {
        const color = hotbarbordercolorinput.value;
        hotbarbordercolorinput.value = color;
        const hotbars = document.querySelectorAll(".item");

        hotbars.forEach(function(hotbar) {
            hotbar.style.borderColor = color;
        });
    });

    let hotbarborderradiusinput;
    hotbarborderradiusinput = document.createElement("input");
    hotbarborderradiusinput.type = "range";
    hotbarborderradiusinput.style.top = "280px";
    hotbarborderradiusinput.style.marginTop = "10px";
    hotbarborderradiusinput.style.position = "absolute";
    hotbarborderradiusinput.value = "0";
    hotbarborderradiusinput.style.left = "50%";
    hotbarborderradiusinput.min = "0";
    hotbarborderradiusinput.max = "30";
    hotbarborderradiusinput.style.transform = "translateX(-50%)";
    clientMainMenu.appendChild(hotbarborderradiusinput);

    hotbarborderradiusinput.addEventListener("input", function() {
        const hotbarrounding = hotbarborderradiusinput.value;
        const hotbars = document.querySelectorAll(".item");

        hotbars.forEach(function(hotbar) {
            hotbar.style.borderRadius = hotbarrounding + "px";
        });
    });

    let crosshairsettingstext
    crosshairsettingstext = document.createElement("div");
    crosshairsettingstext.textContent = "- Crosshair Settings -";
    crosshairsettingstext.style.position = "absolute";
    crosshairsettingstext.style.top = "320px";
    crosshairsettingstext.style.left = "50%";
    crosshairsettingstext.style.transform = "translateX(-50%)";
    crosshairsettingstext.style.fontSize = "20px";
    clientMainMenu.appendChild(crosshairsettingstext);

    let crosshairsettingsinput;
    crosshairsettingsinput = document.createElement("input");
    crosshairsettingsinput.type = "text";
    crosshairsettingsinput.placeholder = "Crosshair URL";
    crosshairsettingsinput.style.backgroundColor = '#AED6F1';
    crosshairsettingsinput.style.border = '3px double #1B4F72';
    crosshairsettingsinput.style.position = "absolute";
    crosshairsettingsinput.style.top = "360px";
    crosshairsettingsinput.value = "https://cdn-icons-png.flaticon.com/512/1527/1527735.png";
    crosshairsettingsinput.style.left = "50%";
    crosshairsettingsinput.style.transform = "translateX(-50%)";
    clientMainMenu.appendChild(crosshairsettingsinput);

    let crosshairurl;

    crosshairsettingsinput.addEventListener('input', function() {
        const crosshair = document.querySelector(".CrossHair");
        if (crosshair) {
            crosshair.style.backgroundImage = `url(${crosshairsettingsinput.value})`;
            crosshairurl = `url(${crosshairsettingsinput.value})`;
        }
    });

    crosshairsettingsinput.addEventListener('mousedown', function(event) {
        event.stopPropagation();
    });

    let keybindsettingstext;
    keybindsettingstext = document.createElement("div");
    keybindsettingstext.textContent = "- Keybind Settings -";
    keybindsettingstext.style.position = "absolute";
    keybindsettingstext.style.top = "420px";
    keybindsettingstext.style.left = "50%";
    keybindsettingstext.style.transform = "translateX(-50%)";
    keybindsettingstext.style.fontSize = "20px";
    clientMainMenu.appendChild(keybindsettingstext);

    let keybindsettingbotton;
    keybindsettingbotton = document.createElement("div");
    keybindsettingbotton.textContent = "- Keybind Settings -";
    keybindsettingbotton.style.position = "absolute";
    keybindsettingbotton.style.top = "420px";
    keybindsettingbotton.style.left = "50%";
    keybindsettingbotton.style.transform = "translateX(-50%)";
    keybindsettingbotton.style.fontSize = "20px";
    clientMainMenu.appendChild(keybindsettingbotton);

        // Create the button element
    const bindbutton = document.createElement("div");
    bindbutton.style.position = "absolute";
    bindbutton.style.top = "470px";
    bindbutton.style.fontSize = "20px";
    bindbutton.style.left = "50%";
    bindbutton.style.transform = "translateX(-50%)";
    bindbutton.style.cursor = "pointer";
    bindbutton.style.borderRadius = "10px";
    bindbutton.style.backgroundColor = "#AED6F1";
    bindbutton.style.color = "#1B4F72";
    bindbutton.style.borderRadius = "10px";
    bindbutton.style.height = "40px";
    bindbutton.style.padding = "8px";
    bindbutton.innerHTML = 'keybind:OFF'; // 初始文本为"ON"
    var isOn = false; // 初始状态为true
    wkey.style.visibility = 'hidden';
    skey.style.visibility = 'hidden';
    akey.style.visibility = 'hidden';
    dkey.style.visibility = 'hidden';
    lmb.style.visibility = 'hidden';
    rmb.style.visibility = 'hidden';
    bindbutton.addEventListener("click", function() {
        isOn = !isOn; // 切换状态
        bindbutton.innerHTML = isOn ? 'keybind:ON' : 'keybind:OFF'; // 根据状态设置按钮文本

        // 根据状态显示或隐藏元素
        wkey.style.visibility = isOn ? 'visible' : 'hidden';
        skey.style.visibility = isOn ? 'visible' : 'hidden';
        akey.style.visibility = isOn ? 'visible' : 'hidden';
        dkey.style.visibility = isOn ? 'visible' : 'hidden';
        lmb.style.visibility = isOn ? 'visible' : 'hidden';
        rmb.style.visibility = isOn ? 'visible' : 'hidden';
        bindMainMenu.style.visibility = isOn ? 'visible' : 'hidden';
    });

    // Append the button element to the desired parent element
    clientMainMenu.appendChild(bindbutton);





    setInterval(function() {
        const color1 = hotbarmaincolorinput.value;
        const color2 = hotbarbordercolorinput.value
        const hotbarrounding = hotbarborderradiusinput.value;
        const hotbars = document.querySelectorAll(".item");
        hotbars.forEach(function(hotbar) {
            hotbar.style.borderRadius = hotbarrounding + "px";
            hotbar.style.borderColor = color2;
            hotbar.style.backgroundColor = color1;
        });
        const crosshair = document.querySelector(".CrossHair");
        if (crosshair) {
            crosshair.textContent = "";
            crosshair.style.backgroundImage = crosshairurl; // Use the crosshairurl variable here
            crosshair.style.backgroundRepeat = "no-repeat";
            crosshair.style.backgroundSize = "contain";
            crosshair.style.width = "30px";
            crosshair.style.height = "30px";
        }
    }, 1000);
})();