Diep.io Custom Points Upgrader. Beta

NEW! custom upgrade builds update! Your upgrade builds will save now! This is still in beta!

// ==UserScript==
// @name         Diep.io Custom Points Upgrader. Beta
// @namespace    http://tampermonkey.net/
// @version      9.7
// @homepage     https://greasyfork.org/scripts/416440
// @description  NEW! custom upgrade builds update! Your upgrade builds will save now! This is still in beta!
// @author       -{Abyss⌬}-ora
// @match        https://diep.io/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
    "use strict";

    const hoverMenu = document.createElement("div");
    hoverMenu.id = "myhover";
    hoverMenu.className = "hover";

    const modMenu = document.createElement("a");
    modMenu.id = "modtab";

    const menuHeader = document.createElement("h1");
    menuHeader.textContent = "-{Abyss⌬}-ora's Mod Menu beta";
    modMenu.appendChild(menuHeader);

    const topRightButton = document.createElement("button");
    topRightButton.id = "topRightButton";
    topRightButton.textContent = "↻";

    const style = document.createElement("style");
    style.type = "text/css";
    style.textContent = `
        #myhover a {
            z-index: 999;
            position: absolute;
            top: 300px;
            right: -260px;
            transition: 0.3s;
            width: 250px;
            padding: 15px;
            background-image: url("https://media.tenor.com/images/f3f5354b7c304bc61882dbb1183885e7/tenor.gif");
            background-color: #555;
            text-decoration: none;
            font-size: 10px;
            font-family: 'Monoton', cursive;
            text-shadow: 1px 1px #000, 2px 2px #555;
            color: white;
            border: double thick white;
            border-radius: 20px;
        }
        #myhover a:hover {
            right: 0;
        }
        .button {
            display: block;
            margin: 5px auto;
            width: 90%;
            text-align: center;
            font-size: 18px;
            font-family: 'Jersey 10', sans-serif;
            color: black;
            background-color: white;
            border-radius: 5px;
            transition: 0.4s;
            cursor: pointer;
        }
        .button:hover {
            transform: translateX(-10px);
        }
        #userInput {
            margin: 5px auto;
            width: 90%;
            padding: 8px;
            font-family: 'Monoton', cursive;
            text-align: center;
        }
        #specialButton {
            display: block;
            margin: 5px auto;
            width: 90%;
            text-align: center;
            font-size: 18px;
            font-family: 'Jersey 10', sans-serif;
            color: white;
            background-color: black;
            border-radius: 5px;
            border-color: white;
            transition: 0.4s;
            cursor: pointer;
            opacity: 0.8;
        }
        #specialButton:hover {
            color: black;
            background-color: darkgray;
            transform: translateX(-10px);
        }
        .popup {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 300px;
            background-image: url("https://media.tenor.com/images/f3f5354b7c304bc61882dbb1183885e7/tenor.gif");
            background-color: white;
            border: double thick white;
            border-radius: 10px;
            padding: 20px;
            z-index: 1000;
            text-shadow: 1px 1px #000, 2px 2px #555;
        }
        .attribute {
            display: flex;
            align-items: center;
            margin-bottom: 10px;
        }
        .attribute div {
            width: 30px;
            height: 30px;
            border: 1px solid #000;
            margin: 0;
        }
        .attribute button {
            background-color: gray;
            border: none;
            color: white;
            font-size: 20px;
            cursor: pointer;
            width: 30px;
            height: 30px;
            margin: 0;
        }
        #pointsCounter {
            text-align: center;
            font-size: 16px;
            margin-bottom: 10px;
        }
        #createBuildButton {
            display: block;
            margin: 20px auto 0 auto;
            width: 80%;
            text-align: center;
            font-size: 18px;
            font-family: 'Jersey 10', sans-serif;
            color: black;
            background-color: white;
            border-radius: 5px;
            border: 2px solid black;
            cursor: pointer;
            padding: 10px;
        }
        #createBuildButton:hover {
            background-color: gray;
            color: white;
        }
        #codeString {
            text-align: center;
            font-size: 18px;
            margin: 10px 0;
        }
        .remove-button {
            background-color: gray;
            border: none;
            color: white;
            font-size: 18px;
            cursor: pointer;
            width: 30px;
            height: 30px;
            margin-right: 5px;
            transition: background-color 0.3s;
        }
        .remove-button:hover {
            background-color: red;
        }
        .close-btn {
            position: absolute;
            top: 5px;
            right: 5px;
            width: 30px;
            height: 30px;
            background-color: black;
            color: white;
            border: none;
            border-radius: 10%;
            cursor: pointer;
            font-size: 18px;
            line-height: 30px;
            text-align: center;
            transition: background-color 0.3s;
            opacity: 0.8;
        }
        .close-btn:hover {
            background-color: red;
        }
        #topRightButton {
            position: absolute;
            top: 10px;
            right: 10px;
            width: 30px;
            height: 30px;
            background-color: black;
            color: white;
            border: none;
            border-radius: 10%;
            cursor: pointer;
            font-size: 18px;
            display: flex;
            justify-content: center;
            align-items: center;
            transition: background-color 0.3s;
            z-index: 1001;
            opacity: 0.8;
        }
        #topRightButton:hover {
            color: red;
        }
        #buildButtonsContainer {
            max-height: 400px;
            overflow-y: scroll;
            margin-left: 5px;
        }
        #buildButtonsContainer {
            -ms-overflow-style: none;
            scrollbar-width: none;
        }
        ::-webkit-scrollbar {
            width: 10px;
        }
        ::-webkit-scrollbar-track {
            background: #f1f1f1;
            border-radius: 10px;
        }
        ::-webkit-scrollbar-thumb {
            background: #888;
            border-radius: 10px;
        }
        ::-webkit-scrollbar-thumb:hover {
            background: #555;
        }
    `;
    document.head.appendChild(style);

    const userInput = document.createElement("input");
    userInput.id = "userInput";
    userInput.type = "text";
    userInput.placeholder = "Enter Username For Quick Spawn";
    userInput.value = localStorage.getItem("quickSpawnUsername") || "";
    modMenu.appendChild(userInput);

    userInput.addEventListener("input", (event) => {
        localStorage.setItem("quickSpawnUsername", event.target.value);
    });

    const buttons = [];

    buttons.forEach((buttonData) => {
        const buttonContainer = document.createElement("div");
        buttonContainer.style.display = "flex";
        buttonContainer.style.alignItems = "center";
        buttonContainer.style.justifyContent = "center";

        const removeButton = document.createElement("button");
        removeButton.className = "remove-button";
        removeButton.textContent = "[-]";
        removeButton.onclick = () => {
            buttonContainer.remove();
            const updatedButtons = JSON.parse(localStorage.getItem("savedButtons")).filter(b => b.name !== buttonData.name);
            localStorage.setItem("savedButtons", JSON.stringify(updatedButtons));

            const updatedRemovedDefaults = JSON.parse(localStorage.getItem("removedDefaults")) || [];
            updatedRemovedDefaults = updatedRemovedDefaults.filter(b => b !== buttonData.name);
            localStorage.setItem("removedDefaults", JSON.stringify(updatedRemovedDefaults));
        };
        buttonContainer.appendChild(removeButton);

        const button = document.createElement("button");
        button.className = "button";
        button.textContent = buttonData.name;
        button.style.backgroundColor = buttonData.color;
        button.onclick = () => {
            const spawnName = userInput.value.trim();
            window.input.execute(`game_spawn ${spawnName}`);
            window.input.execute(`game_stats_build ${buttonData.cmd}`);
        };
        buttonContainer.appendChild(button);

        modMenu.appendChild(buttonContainer);
    });

    const specialButton = document.createElement("button");
    specialButton.id = "specialButton";
    specialButton.textContent = "[+]";

        specialButton.onclick = () => {
        const popup = document.createElement("div");
        popup.className = "popup";

        const closeButton = document.createElement("button");
        closeButton.className = "close-btn";
        closeButton.textContent = "X";
        closeButton.onclick = () => {
            document.body.removeChild(popup);
        };
        popup.appendChild(closeButton);

        const buildNameInput = document.createElement("input");
        buildNameInput.type = "text";
        buildNameInput.placeholder = "Build Name";
        buildNameInput.style.display = "block";
        buildNameInput.style.width = "80%";
        buildNameInput.style.margin = "0 auto 10px auto";
        popup.appendChild(buildNameInput);

        const pointsCounter = document.createElement("div");
        pointsCounter.id = "pointsCounter";
        pointsCounter.textContent = "Points: 33";
        popup.appendChild(pointsCounter);

        const codeString = document.createElement("div");
        codeString.id = "codeString";
        codeString.textContent = "Code: 0";
        popup.appendChild(codeString);

        let totalPoints = 33;
        let code = "";

        const attributes = [
            { name: "Health Regen", color: "rgb(232, 188, 157)" },
            { name: "Max Health", color: "rgb(230, 128, 234)" },
            { name: "Body Damage", color: "rgb(165, 128, 234)" },
            { name: "Bullet Speed", color: "rgb(128, 162, 234)" },
            { name: "Bullet Penetration", color: "rgb(234, 215, 128)" },
            { name: "Bullet Damage", color: "rgb(234, 128, 128)" },
            { name: "Reload", color: "rgb(164, 234, 128)" },
            { name: "Movement Speed", color: "rgb(128, 234, 230)" },
        ];

        attributes.forEach((attribute, index) => {
            const attributeRow = document.createElement("div");
            attributeRow.className = "attribute";

            const minusButton = document.createElement("button");
            minusButton.textContent = "-";
            minusButton.onclick = () => {
                const coloredSquares = Array.from(attributeRow.children).filter(child => child.style.backgroundColor === attribute.color);
                if (coloredSquares.length > 0 && totalPoints < 33) {
                    coloredSquares[coloredSquares.length - 1].style.backgroundColor = "gray";
                    totalPoints++;
                    pointsCounter.textContent = `Points: ${totalPoints}`;
                    code = code.slice(0, -1);
                    codeString.textContent = `Code: ${code}`;
                }
            };
            attributeRow.appendChild(minusButton);

            for (let i = 0; i < 7; i++) {
                const colorDiv = document.createElement("div");
                colorDiv.style.backgroundColor = "gray";
                attributeRow.appendChild(colorDiv);
            }

            const plusButton = document.createElement("button");
            plusButton.textContent = "+";
            plusButton.onclick = () => {
                const graySquares = Array.from(attributeRow.children).filter(child => child.style.backgroundColor === "gray");
                if (graySquares.length > 0 && totalPoints > 0) {
                    graySquares[0].style.backgroundColor = attribute.color;
                    totalPoints--;
                    pointsCounter.textContent = `Points: ${totalPoints}`;
                    code += (index + 1).toString();
                    codeString.textContent = `Code: ${code}`;
                }
            };
            attributeRow.appendChild(plusButton);

            popup.appendChild(attributeRow);
        });

        const createBuildButton = document.createElement("button");
        createBuildButton.id = "createBuildButton";
        createBuildButton.textContent = "Create Build";
        createBuildButton.onclick = () => {
            const buildName = buildNameInput.value.trim();
            if (buildName === "") {
                alert("Please enter a build name.");
                return;
            }

            let savedButtons = JSON.parse(localStorage.getItem("savedButtons")) || [];
            savedButtons.push({ name: buildName, color: "#C0C0C0", cmd: code });
            localStorage.setItem("savedButtons", JSON.stringify(savedButtons));

            const buttonContainer = document.createElement("div");
            buttonContainer.style.display = "flex";
            buttonContainer.style.alignItems = "center";
            buttonContainer.style.justifyContent = "center";

            const removeButton = document.createElement("button");
            removeButton.className = "remove-button";
            removeButton.textContent = "[-]";
            removeButton.onclick = () => {
                buttonContainer.remove();
                const updatedButtons = JSON.parse(localStorage.getItem("savedButtons")) || [];
                let newSavedButtons = updatedButtons.filter(b => b.name !== buildName);
                localStorage.setItem("savedButtons", JSON.stringify(newSavedButtons));

                let updatedRemovedDefaults = JSON.parse(localStorage.getItem("removedDefaults")) || [];
                updatedRemovedDefaults = updatedRemovedDefaults.filter(b => b !== buildName);
                localStorage.setItem("removedDefaults", JSON.stringify(updatedRemovedDefaults));
            };
            buttonContainer.appendChild(removeButton);

            const newButton = document.createElement("button");
            newButton.className = "button";
            newButton.textContent = buildName;
            newButton.style.backgroundColor = "#C0C0C0";
            newButton.onclick = () => {
                const spawnName = userInput.value.trim();
                window.input.execute(`game_spawn ${spawnName}`);
                window.input.execute(`game_stats_build ${code}`);
            };
            buttonContainer.appendChild(newButton);

            buildButtonsContainer.appendChild(buttonContainer);

            document.body.removeChild(popup);
        };
        popup.appendChild(createBuildButton);

        document.body.appendChild(popup);
    };

    modMenu.appendChild(specialButton);
    modMenu.appendChild(topRightButton);
    hoverMenu.appendChild(modMenu);
    document.body.appendChild(hoverMenu);

    document.addEventListener("keydown", (event) => {
        if (event.key === "r" || event.key === "R") {
            const hoverMenu = document.getElementById("myhover");
            if (hoverMenu) {
                hoverMenu.style.display = hoverMenu.style.display === "none" ? "block" : "none";
            }
        }
    });

    window.onload = () => {
        const userInput = document.getElementById("userInput");
        const specialButton = document.getElementById("specialButton");
        const modMenu = document.getElementById("modtab");
        const topRightButton = document.getElementById("topRightButton");

        const savedButtons = JSON.parse(localStorage.getItem("savedButtons")) || [];
        const removedDefaults = JSON.parse(localStorage.getItem("removedDefaults")) || [];

        const defaultButtons = [
            { "name": "L3mon", "color": "#FFFFFF", "cmd": "656565656565654848748487484874877" },
            { "name": "Factory", "color": "#FFFFFF", "cmd": "567456745678567456745678567488888" },
            { "name": "OverLord2.0", "color": "#FFFFFF", "cmd": "456745674567456745674567456788888" },
            { "name": "OverLord", "color": "#FFFFFF", "cmd": "555666555566664444444888888822111" },
            { "name": "Juggernaut", "color": "#FFFFFF", "cmd": "213121312138238238883288327777777" },
            { "name": "SmasherPacifist", "color": "#FFFFFF", "cmd": "7654765476547654765476547654128128128312812812812831281281283" },
            { "name": "SmasherAttacker", "color": "#FFFFFF", "cmd": "7654765476547654765476547654111823823823823823823823823823823" },
            { "name": "SturdyDestroyer", "color": "#FFFFFF", "cmd": "456456456456456456456123123123123" },
            { "name": "Aggressor", "color": "#FFFFFF", "cmd": "456745674567456745674567456722111" },
            { "name": "SturdyAggressor", "color": "#FFFFFF", "cmd": "567856785678567856785678567822111" },
            { "name": "SturdyTriangle", "color": "#FFFFFF", "cmd": "567567567567567567567123123123123" },
            { "name": "Sniper", "color": "#FFFFFF", "cmd": "564456445644564815681568156818188" },
            { "name": "Trapper", "color": "#FFFFFF", "cmd": "567567485675674856756748567484848" },
            { "name": "Semi/Ram/Booster", "color": "#FFFFFF", "cmd": "567823567823148148567823567882314" },
            { "name": "anti-ram", "color": "#FFFFFF", "cmd": "234234562345623456234562345623456" },
            { "name": "pentrat/anti-ram", "color": "#FFFFFF", "cmd": "345345263452634526345263452634526" },
            { "name": "Anni/hybrid", "color": "#FFFFFF", "cmd": "456845684568456845678456782345678" },
            { "name": "OL/overseer", "color": "#FFFFFF", "cmd": "456845684568456845683456782345678" }
        ];

        const allButtons = [...defaultButtons, ...savedButtons.filter(saved => !defaultButtons.some(defaultButton => defaultButton.name === saved.name))];
        const finalButtons = allButtons.filter(buttonData => !removedDefaults.includes(buttonData.name));

        const buildButtonsContainer = document.createElement("div");
        buildButtonsContainer.id = "buildButtonsContainer";
        buildButtonsContainer.style.maxHeight = "400px";
        buildButtonsContainer.style.overflowY = "scroll"; // Always enable the scrollbar
        buildButtonsContainer.style.color = "black";
        modMenu.insertBefore(buildButtonsContainer, specialButton);

        function createButton(buttonData) {
            const buttonContainer = document.createElement("div");
            buttonContainer.style.display = "flex";
            buttonContainer.style.alignItems = "center";
            buttonContainer.style.justifyContent = "center";

            const removeButton = document.createElement("button");
            removeButton.className = "remove-button";
            removeButton.textContent = "[-]";
            removeButton.onclick = () => {
                buttonContainer.remove();

                let updatedButtons = JSON.parse(localStorage.getItem("savedButtons")) || [];
                let newSavedButtons = updatedButtons.filter(b => b.name !== buttonData.name);
                localStorage.setItem("savedButtons", JSON.stringify(newSavedButtons));

                let updatedRemovedDefaults = JSON.parse(localStorage.getItem("removedDefaults")) || [];
                updatedRemovedDefaults.push(buttonData.name);
                localStorage.setItem("removedDefaults", JSON.stringify(updatedRemovedDefaults));
            };
            buttonContainer.appendChild(removeButton);

            const button = document.createElement("button");
            button.className = "button";
            button.textContent = buttonData.name;
            button.style.backgroundColor = buttonData.color;
            button.onclick = () => {
                const spawnName = userInput.value.trim();
                window.input.execute(`game_spawn ${spawnName}`);
                window.input.execute(`game_stats_build ${buttonData.cmd}`);
            };
            buttonContainer.appendChild(button);

            buildButtonsContainer.appendChild(buttonContainer);
        }

        finalButtons.forEach(buttonData => createButton(buttonData));

        const createBuildButton = document.getElementById("createBuildButton");
        createBuildButton.onclick = () => {
            const buildNameInput = document.getElementById("buildNameInput");
            const buildName = buildNameInput.value.trim();
            if (buildName === "") {
                alert("Please enter a build name.");
                return;
            }

            const code = "some_code_here";

            let savedButtons = JSON.parse(localStorage.getItem("savedButtons")) || [];
            savedButtons.push({ name: buildName, color: "#C0C0C0", cmd: code });
            localStorage.setItem("savedButtons", JSON.stringify(savedButtons));

            createButton({ name: buildName, color: "#C0C0C0", cmd: code });

            const popup = document.getElementById("popup");
            document.body.removeChild(popup);
        };
    };

    document.getElementById("userInput").addEventListener("input", (event) => {
        localStorage.setItem("quickSpawnUsername", event.target.value);
    });

    topRightButton.addEventListener("click", () => {
        const resetPopup = document.createElement("div");
        resetPopup.className = "popup";

        const closeButton = document.createElement("button");
        closeButton.className = "close-btn";
        closeButton.textContent = "X";
        closeButton.onclick = () => {
            document.body.removeChild(resetPopup);
        };
        resetPopup.appendChild(closeButton);

        const confirmationMessage = document.createElement("div");
        confirmationMessage.textContent = "Do you really want to reset to default builds?";
        confirmationMessage.style.textAlign = "center";
        confirmationMessage.style.marginBottom = "20px";
        resetPopup.appendChild(confirmationMessage);

        const buttonsContainer = document.createElement("div");
        buttonsContainer.style.display = "flex";
        buttonsContainer.style.justifyContent = "space-between";

        const noButton = document.createElement("button");
        noButton.className = "button";
        noButton.textContent = "NO";
        noButton.onclick = () => {
            document.body.removeChild(resetPopup);
        };
        buttonsContainer.appendChild(noButton);

        const yesButton = document.createElement("button");
        yesButton.className = "button";
        yesButton.textContent = "YES";
        yesButton.onclick = () => {
            localStorage.removeItem("savedButtons");
            localStorage.removeItem("removedDefaults");
            location.reload();
        };
        buttonsContainer.appendChild(yesButton);

        resetPopup.appendChild(buttonsContainer);
        document.body.appendChild(resetPopup);
    });

})();