Predator Stack - New UI

Customizable predator Stack Keys. With a beautiful Menu

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

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

Tendrás que instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Tendrás que instalar una extensión como Tampermonkey antes de poder instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

Advertisement:

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

Advertisement:

// ==UserScript==
// @name         Predator Stack - New UI
// @license      MIT
// @namespace    http://tampermonkey.net/
// @version      2.5
// @description  Customizable predator Stack Keys. With a beautiful Menu
// @author       Voyager
// @match        *://diep.io/*
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==

(function() {
    'use strict';

    // 1. Load saved settings or use default values
    let stackKey5 = GM_getValue('stackKey5', 'b'); // Reload 5
    let stackKey6 = GM_getValue('stackKey6', 'g'); // Reload 6
    let stackKey7 = GM_getValue('stackKey7', 'v'); // Reload 7
    let toggleKey = GM_getValue('toggleKey', 'i'); // Menu toggle

    // Load saved position or use default coordinates
    let menuX = GM_getValue('menuX', '20px');
    let menuY = GM_getValue('menuY', '20px');

    // First time install detection
    let yaInstalado = GM_getValue('yaInstalado', false);
    let menuVisible = !yaInstalado;
    let activeBindingInput = null;

    // 2. CSS Styles for the overlay menu
    const style = document.createElement('style');
    style.textContent = `
        #predator-menu {
            position: fixed;
            top: ${menuY};
            left: ${menuX};
            background: rgba(17, 17, 17, 0.95);
            border: 2px solid #00b2e1;
            border-radius: 8px;
            padding: 15px;
            color: white;
            font-family: 'Ubuntu', sans-serif;
            z-index: 999999;
            box-shadow: 0 4px 20px rgba(0,0,0,0.7);
            width: 230px;
            display: ${menuVisible ? 'block' : 'none'};
            user-select: none;
        }
        #predator-menu-header {
            margin: -15px -15px 10px -15px;
            padding: 10px;
            background: rgba(0, 178, 225, 0.15);
            border-bottom: 1px solid #00b2e1;
            border-top-left-radius: 6px;
            border-top-right-radius: 6px;
            cursor: move;
        }
        #predator-menu-header h3 {
            margin: 0;
            font-size: 14px;
            text-align: center;
            color: #00b2e1;
            text-transform: uppercase;
            letter-spacing: 1px;
        }
        .menu-welcome {
            font-size: 11px;
            color: #aaa;
            text-align: center;
            margin-bottom: 12px;
            line-height: 14px;
        }
        .menu-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
            font-size: 12px;
        }
        .menu-row.separador {
            border-top: 1px solid #333;
            padding-top: 10px;
            margin-top: 5px;
        }
        .menu-btn {
            width: 55px;
            background: #222;
            border: 1px solid #555;
            color: #fff;
            text-align: center;
            padding: 4px;
            border-radius: 4px;
            text-transform: uppercase;
            font-weight: bold;
            cursor: pointer;
            font-size: 11px;
            transition: background 0.2s, border-color 0.2s;
        }
        .menu-btn:hover {
            border-color: #00b2e1;
            background: #2a2a2a;
        }
        .menu-btn.listening {
            border-color: #ffb86c !important;
            color: #ffb86c;
            background: #33251a;
        }
    `;
    document.head.appendChild(style);

    // 3. Create HTML structure
    const menuContainer = document.createElement('div');
    menuContainer.id = "predator-menu";
    menuContainer.innerHTML = `
        <div id="predator-menu-header">
            <h3>Predator Stack</h3>
        </div>
        <div class="menu-welcome">Initial Setup! Click any box and press a key to bind it. This menu will start hidden next time.</div>

        <div class="menu-row">
            <span>Stack 1 (Reload 5):</span>
            <div id="btn-key5" class="menu-btn">${stackKey5.toUpperCase()}</div>
        </div>
        <div class="menu-row">
            <span>Stack 2 (Reload 6):</span>
            <div id="btn-key6" class="menu-btn">${stackKey6.toUpperCase()}</div>
        </div>
        <div class="menu-row">
            <span>Stack 3 (Reload 7):</span>
            <div id="btn-key7" class="menu-btn">${stackKey7.toUpperCase()}</div>
        </div>
        <div class="menu-row separador">
            <span style="color: #ffb86c;">Show/Hide Menu:</span>
            <div id="btn-toggle" class="menu-btn" style="border-color: #ffb86c; color: #ffb86c;">${toggleKey.toUpperCase()}</div>
        </div>
    `;
    document.body.appendChild(menuContainer);

    // 4. Capture DOM Elements
    const btnKey5 = document.getElementById('btn-key5');
    const btnKey6 = document.getElementById('btn-key6');
    const btnKey7 = document.getElementById('btn-key7');
    const btnToggle = document.getElementById('btn-toggle');
    const menuDiv = document.getElementById('predator-menu');
    const menuHeader = document.getElementById('predator-menu-header');

    // Aux function to get variable values safely
    function getKeyValueByButton(element) {
        if (element === btnKey5) return stackKey5;
        if (element === btnKey6) return stackKey6;
        if (element === btnKey7) return stackKey7;
        if (element === btnToggle) return toggleKey;
        return '';
    }

    // 5. Click to Rebind Event Handler
    const setupRebind = (element) => {
        element.addEventListener('click', () => {
            if (activeBindingInput === element) {
                element.classList.remove('listening');
                element.textContent = getKeyValueByButton(element).toUpperCase();
                activeBindingInput = null;
                return;
            }
            if (activeBindingInput) {
                activeBindingInput.classList.remove('listening');
                activeBindingInput.textContent = getKeyValueByButton(activeBindingInput).toUpperCase();
            }
            activeBindingInput = element;
            element.classList.add('listening');
            element.textContent = '...';
        });
    };

    setupRebind(btnKey5);
    setupRebind(btnKey6);
    setupRebind(btnKey7);
    setupRebind(btnToggle);

    // 6. Global Keydown Router (Handles both Binds and Toggles)
    window.addEventListener('keydown', (e) => {
        const pressedKey = e.key.toLowerCase();

        // SCENARIO A: The menu is actively waiting to record a keybind
        if (activeBindingInput) {
            e.preventDefault();
            e.stopPropagation();

            if (pressedKey === 'escape') {
                activeBindingInput.classList.remove('listening');
                btnKey5.textContent = stackKey5.toUpperCase();
                btnKey6.textContent = stackKey6.toUpperCase();
                btnKey7.textContent = stackKey7.toUpperCase();
                btnToggle.textContent = toggleKey.toUpperCase();
                activeBindingInput = null;
                return;
            }

            if (activeBindingInput === btnKey5) { stackKey5 = pressedKey; GM_setValue('stackKey5', pressedKey); btnKey5.textContent = pressedKey.toUpperCase(); }
            if (activeBindingInput === btnKey6) { stackKey6 = pressedKey; GM_setValue('stackKey6', pressedKey); btnKey6.textContent = pressedKey.toUpperCase(); }
            if (activeBindingInput === btnKey7) { stackKey7 = pressedKey; GM_setValue('stackKey7', pressedKey); btnKey7.textContent = pressedKey.toUpperCase(); }
            if (activeBindingInput === btnToggle) {
                toggleKey = pressedKey;
                GM_setValue('toggleKey', pressedKey);
                btnToggle.textContent = pressedKey.toUpperCase();
            }

            activeBindingInput.classList.remove('listening');
            activeBindingInput = null;
            actualizarScriptInyectado();
            return;
        }

        // SCENARIO B: Toggle menu open/close status
        if (pressedKey === toggleKey) {
            menuVisible = !menuVisible;
            menuDiv.style.display = menuVisible ? 'block' : 'none';

            if (!yaInstalado) {
                yaInstalado = true;
                GM_setValue('yaInstalado', true);
            }
        }
    }, true);

    // 7. Menu Dragging Logic
    let isDragging = false;
    let offsetX, offsetY;

    menuHeader.addEventListener('mousedown', (e) => {
        if (activeBindingInput) return;
        isDragging = true;
        offsetX = e.clientX - menuDiv.offsetLeft;
        offsetY = e.clientY - menuDiv.offsetTop;
    });

    document.addEventListener('mousemove', (e) => {
        if (!isDragging) return;
        let x = e.clientX - offsetX;
        let y = e.clientY - offsetY;
        menuDiv.style.left = `${x}px`;
        menuDiv.style.top = `${y}px`;
    });

    document.addEventListener('mouseup', () => {
        if (isDragging) {
            isDragging = false;
            GM_setValue('menuX', menuDiv.style.left);
            GM_setValue('menuY', menuDiv.style.top);
        }
    });

    // 8. Dynamic Game Environment Script Injection
    let injectedScript = null;

    function actualizarScriptInyectado() {
        if (injectedScript) injectedScript.remove();

        injectedScript = document.createElement('script');
        injectedScript.textContent = `
            (function() {
                const key5 = "${stackKey5}";
                const key6 = "${stackKey6}";
                const key7 = "${stackKey7}";
                const menuToggle = "${toggleKey}";

                function simulateKey(code, keyCode, type) {
                    const event = new KeyboardEvent(type, {
                        code: code,
                        keyCode: keyCode,
                        which: keyCode,
                        bubbles: true,
                        cancelable: true
                    });
                    const target = document.querySelector('canvas') || document;
                    target.dispatchEvent(event);
                }

                function shoot(duration) {
                    simulateKey("Space", 32, "keydown");
                    setTimeout(() => {
                        simulateKey("Space", 32, "keyup");
                    }, duration);
                }

                function executeStack(t1, t2, t3) {
                    shoot(t1);
                    setTimeout(() => shoot(300), t2);
                    setTimeout(() => {
                        simulateKey("KeyE", 69, "keydown");
                        setTimeout(() => simulateKey("KeyE", 69, "keyup"), 50);
                    }, t3);
                }

                if (window.predatorHandler) {
                    window.removeEventListener('keydown', window.predatorHandler, true);
                }

                window.predatorHandler = function(e) {
                    if (e.repeat || e.key.toLowerCase() === menuToggle) return;
                    const key = e.key.toLowerCase();

                    if (key === key5) executeStack(50, 900, 1800);  // Reload 5
                    if (key === key6) executeStack(50, 825, 1700);  // Reload 6 (Updated Values)
                    if (key === key7) executeStack(50, 750, 1500);  // Reload 7
                };

                window.addEventListener('keydown', window.predatorHandler, true);
            })();
        `;
        (document.head || document.documentElement).appendChild(injectedScript);
    }

    // Launch setup
    actualizarScriptInyectado();

})();