Canadian100's client (survev.io)

Aimbot, Auto-Shoot, Spinbot, Explosive Warning, Red Lines, See Through Buildings, Enemy Health Bars for Survev.io with GUI toggle system, brightness changer, opacity changerr, fps regualtor, and other key features.

Pada tanggal 11 April 2025. Lihat %(latest_version_link).

// ==UserScript==
// @name         Canadian100's client (survev.io)
// @namespace    http://tampermonkey.net/
// @version      4.4
// @description  Aimbot, Auto-Shoot, Spinbot, Explosive Warning, Red Lines, See Through Buildings, Enemy Health Bars for Survev.io with GUI toggle system, brightness changer, opacity changerr, fps regualtor, and other key features.
// @author       Canadian100
// @match        *://survev.io/*
// @grant        unsafeWindow
// @run-at       document-end
// ==/UserScript==

(function () {
    // Default feature states
    let aimbotEnabled = false;
    let autoShootEnabled = false;
    let spinbotEnabled = false;
    let explosiveWarningEnabled = true;
    let drawEnemyLines = false;
    let seeThroughBuildingsEnabled = false;
    let showHealthBars = false;
    let espEnabled = false;
    let meleeAimbotEnabled = false; // Melee aimbot state

    // FPS and Ping variables
    let fps = 0;
    let ping = 0;
    let lastTime = performance.now();
    let frames = 0;

    // Canvas Overlay Setup
    const canvas = document.createElement('canvas');
    canvas.style.position = 'fixed';
    canvas.style.top = '0';
    canvas.style.left = '0';
    canvas.style.pointerEvents = 'none';
    canvas.style.zIndex = '9998';
    document.body.appendChild(canvas);
    const ctx = canvas.getContext('2d');

    // Update Canvas Size
    function updateCanvasSize() {
        canvas.width = window.innerWidth;
        canvas.height = window.innerHeight;
    }
    window.addEventListener('resize', updateCanvasSize);
    updateCanvasSize();

    // FPS Calculation
    function updateFPS() {
        const currentTime = performance.now();
        frames++;
        if (currentTime - lastTime >= 1000) {
            fps = frames;
            frames = 0;
            lastTime = currentTime;
        }
    }

    // Ping Calculation
    function updatePing() {
        const startTime = performance.now();
        fetch("https://www.google.com/") // Simple ping test
            .then(response => response.text())
            .then(() => {
                const endTime = performance.now();
                ping = endTime - startTime;
            })
            .catch(() => ping = 0); // If request fails, set ping to 0
    }

    // Stats Box Setup
    const statsBox = document.createElement('div');
    statsBox.style.position = 'fixed';
    statsBox.style.top = '20px';
    statsBox.style.left = '20px';
    statsBox.style.padding = '15px';
    statsBox.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
    statsBox.style.borderRadius = '10px';
    statsBox.style.color = 'white';
    statsBox.style.fontFamily = 'Arial, sans-serif';
    statsBox.style.zIndex = '9999';
    statsBox.style.boxShadow = '0 0 10px rgba(255, 255, 255, 0.5)';
    document.body.appendChild(statsBox);

    const fpsElement = document.createElement('div');
    const pingElement = document.createElement('div');
    const killsElement = document.createElement('div');

    fpsElement.style.fontSize = '18px';
    pingElement.style.fontSize = '18px';
    killsElement.style.fontSize = '18px';

    statsBox.appendChild(fpsElement);
    statsBox.appendChild(pingElement);
    statsBox.appendChild(killsElement);

    // Update Stats Box
    function updateStats() {
        fpsElement.textContent = `FPS: ${fps}`;
        pingElement.textContent = `Ping: ${ping.toFixed(2)} ms`;
        killsElement.textContent = `Kills: ${unsafeWindow.activePlayer.kills}`;
    }

    setInterval(() => {
        updateFPS();
        updatePing();
        updateStats();
    }, 1000 / 60); // Update every 60 FPS

    // Create the Popup GUI
    const popupWindow = document.createElement('div');
    popupWindow.style.position = 'fixed';
    popupWindow.style.top = '50%';
    popupWindow.style.left = '50%';
    popupWindow.style.transform = 'translate(-50%, -50%)';
    popupWindow.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
    popupWindow.style.color = 'white';
    popupWindow.style.padding = '20px';
    popupWindow.style.borderRadius = '10px';
    popupWindow.style.display = 'none';
    popupWindow.style.zIndex = '9999';
    document.body.appendChild(popupWindow);

    popupWindow.innerHTML = `
        <h2>Enable Features</h2>
        <label><input type="checkbox" id="aimbotCheckbox"> Aimbot [X]</label><br>
        <label><input type="checkbox" id="autoShootCheckbox"> Auto-Shoot [Z]</label><br>
        <label><input type="checkbox" id="spinbotCheckbox"> Spinbot [C]</label><br>
        <label><input type="checkbox" id="explosiveWarningCheckbox"> Explosive Warning [I]</label><br>
        <label><input type="checkbox" id="enemyLinesCheckbox"> Red Lines to Enemies [K]</label><br>
        <label><input type="checkbox" id="seeThroughCheckbox"> See Through Buildings [Y]</label><br>
        <label><input type="checkbox" id="healthBarCheckbox"> Show Enemy Health Bars [H]</label><br>
        <label><input type="checkbox" id="espCheckbox"> ESP Line to Player [E]</label><br>
        <label><input type="checkbox" id="meleeAimbotCheckbox"> Melee Aimbot [M]</label><br> <!-- Melee checkbox -->
        <button id="closePopupButton">Close</button>
    `;

    // Get references to checkboxes
    const aimbotCheckbox = document.getElementById('aimbotCheckbox');
    const autoShootCheckbox = document.getElementById('autoShootCheckbox');
    const spinbotCheckbox = document.getElementById('spinbotCheckbox');
    const explosiveWarningCheckbox = document.getElementById('explosiveWarningCheckbox');
    const enemyLinesCheckbox = document.getElementById('enemyLinesCheckbox');
    const seeThroughCheckbox = document.getElementById('seeThroughCheckbox');
    const healthBarCheckbox = document.getElementById('healthBarCheckbox');
    const espCheckbox = document.getElementById('espCheckbox');
    const meleeAimbotCheckbox = document.getElementById('meleeAimbotCheckbox'); // Melee checkbox reference
    const closePopupButton = document.getElementById('closePopupButton');

    // Toggle Popup visibility
    function togglePopup() {
        popupWindow.style.display = popupWindow.style.display === 'none' ? 'block' : 'none';
    }

    closePopupButton.addEventListener('click', togglePopup);

    // Keybinds handling
    function handleKeyPress(event) {
        switch (event.key.toLowerCase()) {
            case 'x':
                aimbotEnabled = !aimbotEnabled;
                aimbotCheckbox.checked = aimbotEnabled;
                break;
            case 'z':
                autoShootEnabled = !autoShootEnabled;
                autoShootCheckbox.checked = autoShootEnabled;
                break;
            case 'c':
                spinbotEnabled = !spinbotEnabled;
                spinbotCheckbox.checked = spinbotEnabled;
                break;
            case 'i':
                explosiveWarningEnabled = !explosiveWarningEnabled;
                explosiveWarningCheckbox.checked = explosiveWarningEnabled;
                break;
            case 'k':
                drawEnemyLines = !drawEnemyLines;
                enemyLinesCheckbox.checked = drawEnemyLines;
                break;
            case 'y':
                seeThroughBuildingsEnabled = !seeThroughBuildingsEnabled;
                seeThroughCheckbox.checked = seeThroughBuildingsEnabled;
                break;
            case 'h':
                showHealthBars = !showHealthBars;
                healthBarCheckbox.checked = showHealthBars;
                break;
            case 'e':
                espEnabled = !espEnabled;
                espCheckbox.checked = espEnabled;
                break;
            case 'm': // Keybind for melee aimbot
                meleeAimbotEnabled = !meleeAimbotEnabled;
                meleeAimbotCheckbox.checked = meleeAimbotEnabled;
                break;
            case 't':
                togglePopup();
                break;
        }
    }

    window.addEventListener('keydown', handleKeyPress);

    // Synchronize checkboxes and feature states
    [aimbotCheckbox, autoShootCheckbox, spinbotCheckbox, explosiveWarningCheckbox, enemyLinesCheckbox, seeThroughCheckbox, healthBarCheckbox, espCheckbox, meleeAimbotCheckbox].forEach(cb => {
        cb.addEventListener('change', () => {
            aimbotEnabled = aimbotCheckbox.checked;
            autoShootEnabled = autoShootCheckbox.checked;
            spinbotEnabled = spinbotCheckbox.checked;
            explosiveWarningEnabled = explosiveWarningCheckbox.checked;
            drawEnemyLines = enemyLinesCheckbox.checked;
            seeThroughBuildingsEnabled = seeThroughCheckbox.checked;
            showHealthBars = healthBarCheckbox.checked;
            espEnabled = espCheckbox.checked;
            meleeAimbotEnabled = meleeAimbotCheckbox.checked;
        });
    });
    // Aimbot Function
    function aimbot() {
        if (aimbotEnabled) {
            let closestEnemy = null;
            let closestDistance = Infinity;

            // Find the closest enemy within the player's view
            unsafeWindow.players.forEach(player => {
                if (player.team !== unsafeWindow.activePlayer.team) {
                    // Check if the enemy is on screen
                    const distance = Math.sqrt(Math.pow(unsafeWindow.activePlayer.x - player.x, 2) + Math.pow(unsafeWindow.activePlayer.y - player.y, 2));
                    const screenBounds = {
                        top: 0,
                        left: 0,
                        right: window.innerWidth,
                        bottom: window.innerHeight
                    };

                    // Check if the enemy is within screen bounds
                    if (player.x > screenBounds.left && player.x < screenBounds.right && player.y > screenBounds.top && player.y < screenBounds.bottom) {
                        if (distance < closestDistance) {
                            closestDistance = distance;
                            closestEnemy = player;
                        }
                    }
                }
            });

            if (closestEnemy) {
                const angleToEnemy = Math.atan2(closestEnemy.y - unsafeWindow.activePlayer.y, closestEnemy.x - unsafeWindow.activePlayer.x);
                unsafeWindow.activePlayer.rotation = angleToEnemy;
                if (autoShootEnabled) {
                    // Auto shoot if enabled
                    unsafeWindow.activePlayer.shoot();
                }
            }
        }
    }
    // Spinbot Function
    function spinbot() {
        if (spinbotEnabled) {
            // Rotate the player character in a continuous spinning motion
            unsafeWindow.activePlayer.rotation += Math.PI / 180; // Rotate by 1 degree every frame
        }
    }
    // Melee Aimbot Function (Targets enemies within 50px distance)
    function meleeAimbot() {
        if (meleeAimbotEnabled) {
            let closestEnemy = null;
            let closestDistance = 50; // Distance threshold for melee aimbot

            // Find the closest enemy within the melee range
            unsafeWindow.players.forEach(player => {
                if (player.team !== unsafeWindow.activePlayer.team) {
                    const distance = Math.sqrt(Math.pow(unsafeWindow.activePlayer.x - player.x, 2) + Math.pow(unsafeWindow.activePlayer.y - player.y, 2));
                    if (distance < closestDistance) {
                        closestDistance = distance;
                        closestEnemy = player;
                    }
                }
            });

            if (closestEnemy) {
                const angleToEnemy = Math.atan2(closestEnemy.y - unsafeWindow.activePlayer.y, closestEnemy.x - unsafeWindow.activePlayer.x);
                unsafeWindow.activePlayer.rotation = angleToEnemy;
                unsafeWindow.activePlayer.shoot(); // Perform melee attack or shooting
            }
        }
    }
    // Main loop to update features every frame
    setInterval(() => {
        if (aimbotEnabled || meleeAimbotEnabled) {
            aimbot();
            meleeAimbot(); // Check for melee aimbot at the same time
        }
        if (spinbotEnabled) {
            spinbot();
        }
    }, 1000 / 60); // Update every 60 FPS

})(); // Closing the IIFE
(function () {
    // Optimize FPS performance in web-based games
    function optimizeFPS() {
        // Request animation frame to sync the FPS with the browser's refresh rate
        function loop() {
            // Remove unnecessary rendering/animations
            cancelAnimationFrame(loopID);
            loopID = requestAnimationFrame(loop);
        }

        let loopID = requestAnimationFrame(loop);

        // Reduce memory usage by disabling certain features that are not necessary
        function reduceMemoryUsage() {
            if (typeof window.performance !== 'undefined') {
                // Garbage collection is done automatically, but we can try to reduce memory-intensive operations
                window.performance.memory = null;
            }
        }

        // Automatically lower graphics or display settings based on current performance
        function adjustGraphicsSettings() {
            const fpsThreshold = 30; // If FPS is below this threshold, lower the settings
            let currentFPS = 0;

            // Calculate FPS (frames per second) in a more efficient way
            let frames = 0;
            let lastTime = performance.now();
            function calculateFPS() {
                frames++;
                let currentTime = performance.now();
                if (currentTime - lastTime >= 1000) {
                    currentFPS = frames;
                    frames = 0;
                    lastTime = currentTime;

                    if (currentFPS < fpsThreshold) {
                        // Reduce graphics (e.g., disable effects, lower resolution)
                        console.log("FPS is low, lowering graphics settings...");
                        // Example: Disable some graphical elements
                        document.body.style.background = "#000"; // Simple example to darken the screen
                    }
                }
            }

            setInterval(calculateFPS, 1000); // Check FPS every second
        }

        // Optimize the environment for performance
        function optimizeEnvironment() {
            // Disable unnecessary animations
            document.body.style.animation = 'none';
            document.body.style.transition = 'none';

            // Disable unnecessary JavaScript timers (e.g., setInterval, setTimeout)
            const originalSetInterval = window.setInterval;
            window.setInterval = function (callback, delay) {
                if (delay > 1000) { // If the interval is too fast, delay or disable it
                    return originalSetInterval(callback, 1000);
                }
                return originalSetInterval(callback, delay);
            };
        }

        // Reduce background tasks and optimize the browser for gaming
        function optimizeBrowser() {
            // Disable unused tabs or reduce background tasks
            const visibleTabs = [...document.querySelectorAll('iframe')];
            visibleTabs.forEach(tab => {
                tab.style.visibility = 'hidden'; // Hide any hidden iframe or background content
            });

            // Enable performance-enhancing modes like "requestAnimationFrame"
            window.requestAnimationFrame = (function () {
                return function (callback) {
                    setTimeout(callback, 1000 / 60); // Cap the FPS at 60
                };
            })();
        }

        // Start optimizations
        reduceMemoryUsage();
        adjustGraphicsSettings();
        optimizeEnvironment();
        optimizeBrowser();
    }

    // Execute the function for optimizing FPS and lag reduction
    optimizeFPS();
})();
(function () {
    // Optimizing the ping by reducing unnecessary network requests
    function optimizeNetworkRequests() {
        // Prevent automatic background refreshes
        const originalFetch = window.fetch;
        window.fetch = function (url, options) {
            // Log requests to see if there are unnecessary fetches
            console.log('Fetching:', url);

            // If the request is to an unnecessary endpoint, block it (this is just an example)
            if (url.includes('unnecessary_resource')) {
                return Promise.resolve(new Response(''));
            }

            // Otherwise, allow the fetch to proceed normally
            return originalFetch(url, options);
        };

        // Disable any unnecessary WebSocket connections or long-polling events
        const originalWebSocket = window.WebSocket;
        window.WebSocket = function (url, protocols) {
            // Block specific WebSocket connections (example)
            if (url.includes('unnecessary_socket')) {
                return null;
            }
            return new originalWebSocket(url, protocols);
        };

        // Reduce background network usage by blocking certain requests
        function blockUnwantedRequests() {
            const originalXMLHttpRequest = window.XMLHttpRequest;
            window.XMLHttpRequest = function () {
                const xhr = new originalXMLHttpRequest();
                const originalSend = xhr.send;
                xhr.send = function (body) {
                    // Block requests that aren't essential for gameplay
                    if (xhr._url.includes('unwanted_resource')) {
                        console.log('Blocking request:', xhr._url);
                        return; // Don't send this request
                    }
                    return originalSend.call(xhr, body);
                };
                return xhr;
            };
        }

        // Execute blocking function to minimize unnecessary traffic
        blockUnwantedRequests();
    }

    // Optimize the game environment by reducing unnecessary resource loading
    function optimizeResourceLoading() {
        // Disable unnecessary image, script, or video loading
        const originalImage = HTMLImageElement.prototype.src;
        HTMLImageElement.prototype.src = function (src) {
            if (src.includes('high_resolution_image')) {
                console.log('Blocking high-resolution image load:', src);
                return;
            }
            return originalImage.apply(this, arguments);
        };

        // Disable background processes that can increase latency
        function stopBackgroundTasks() {
            // Blocking certain animation or resource-intensive operations that may cause lag
            document.body.style.animation = 'none';
            document.body.style.transition = 'none';
        }

        stopBackgroundTasks();
    }

    // Reduce background process interference
    function manageBackgroundProcesses() {
        // Disable unused tabs or resources to reduce background interference
        const hiddenTabs = document.querySelectorAll('iframe');
        hiddenTabs.forEach(tab => {
            tab.style.visibility = 'hidden'; // Hide inactive tabs or iframes to reduce resources used
        });

        // Disable animations and transitions that could increase load and delay
        document.body.style.animation = 'none';
        document.body.style.transition = 'none';
    }

    // Improve the game experience by reducing unnecessary resources and improving connection handling
    function improveGameConnection() {
        // Automatically retry failed connections, ensuring more stable gameplay
        window.addEventListener('offline', () => {
            console.log('Connection lost, retrying...');
            // Try to reconnect when the connection is restored
            setTimeout(() => {
                location.reload();
            }, 5000);
        });

        // Retry any important game-related requests if they fail
        function retryFailedRequests() {
            const originalFetch = window.fetch;
            window.fetch = function (url, options) {
                return originalFetch(url, options).catch((error) => {
                    console.log('Fetch failed, retrying...', url);
                    // Retry the fetch after a delay
                    return new Promise((resolve) => {
                        setTimeout(() => resolve(fetch(url, options)), 2000);
                    });
                });
            };
        }

        retryFailedRequests();
    }

    // Initiate optimization functions
    function optimizePing() {
        optimizeNetworkRequests();
        optimizeResourceLoading();
        manageBackgroundProcesses();
        improveGameConnection();
    }

    // Run the ping optimization every 5 seconds to continuously adjust settings
    setInterval(optimizePing, 5000); // Check every 5 seconds to optimize the game

    console.log('Ping optimization started...');
})();
(function () {
    function showHealthPercentage(barElement, currentHealth, maxHealth) {
        if (!barElement || typeof currentHealth !== 'number' || typeof maxHealth !== 'number') return;

        const percentage = Math.round((currentHealth / maxHealth) * 100);

        let percentageText = barElement.querySelector('.health-percent');
        if (!percentageText) {
            percentageText = document.createElement('div');
            percentageText.className = 'health-percent';

            Object.assign(percentageText.style, {
                position: 'absolute',
                width: '100%',
                height: '100%',
                display: 'flex',
                alignItems: 'center',
                justifyContent: 'center',
                top: '0',
                left: '0',
                color: 'white',
                fontWeight: 'bold',
                fontSize: '14px',
                textShadow: '0 0 5px black',
                pointerEvents: 'none',
            });

            if (getComputedStyle(barElement).position === 'static') {
                barElement.style.position = 'relative';
            }

            barElement.appendChild(percentageText);
        }

        percentageText.textContent = `${percentage}%`;
    }

    // 🔁 Example auto-update loop (modify as needed)
    setInterval(() => {
        const healthBar = document.getElementById('health-bar');
        const player = unsafeWindow.activePlayer;

        if (player && healthBar) {
            showHealthPercentage(healthBar, player.health, player.maxHealth);
        }
    }, 200); // update every 200ms
})();
(function () {
    // Declare the GUI container but don't append it yet
    let guiContainer;

    // Function to create and display the GUI container when the 'L' key is pressed
    function createGUI() {
        // Create the draggable GUI container
        guiContainer = document.createElement('div');
        guiContainer.style.position = 'fixed';
        guiContainer.style.left = '50%';
        guiContainer.style.top = '50%';
        guiContainer.style.transform = 'translate(-50%, -50%)';
        guiContainer.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
        guiContainer.style.padding = '20px';
        guiContainer.style.borderRadius = '10px';
        guiContainer.style.color = 'white';
        guiContainer.style.zIndex = '9999';
        guiContainer.style.display = 'none'; // Initially hidden
        guiContainer.style.display = 'flex';
        guiContainer.style.flexDirection = 'column'; // Stack elements vertically
        guiContainer.style.gap = '10px'; // Adds space between elements
        guiContainer.style.maxWidth = '150px'; // Max width of the HUD container
        guiContainer.style.width = '100%'; // Allows for responsive resizing while respecting max-width
        document.body.appendChild(guiContainer);

        // Add title to the GUI
        const title = document.createElement('h2');
        title.innerText = 'Game Settings';
        guiContainer.appendChild(title);

        // Brightness control label
        const brightnessLabel = document.createElement('label');
        brightnessLabel.innerText = 'Set Game Brightness: ';
        guiContainer.appendChild(brightnessLabel);

        // Create brightness slider
        const brightnessSlider = document.createElement('input');
        brightnessSlider.type = 'range';
        brightnessSlider.min = '0';
        brightnessSlider.max = '2';
        brightnessSlider.step = '0.01';
        brightnessSlider.value = '1'; // Default brightness
        guiContainer.appendChild(brightnessSlider);

        // Event listener for brightness slider
        brightnessSlider.addEventListener('input', function () {
            // Update the brightness of the game
            const brightnessValue = brightnessSlider.value;
            document.body.style.filter = `brightness(${brightnessValue})`;
        });

        // Opacity control label for environment elements (trees, buildings, containers, bushes)
        const opacityLabel = document.createElement('label');
        opacityLabel.innerText = 'Set Environment Opacity: ';
        guiContainer.appendChild(opacityLabel);

        // Create opacity slider
        const opacitySlider = document.createElement('input');
        opacitySlider.type = 'range';
        opacitySlider.min = '0';
        opacitySlider.max = '1';
        opacitySlider.step = '0.01';
        opacitySlider.value = '1'; // Default opacity
        guiContainer.appendChild(opacitySlider);

        // Event listener for opacity slider
        opacitySlider.addEventListener('input', function () {
            // Update opacity of in-game objects (trees, buildings, containers, bushes)
            const opacityValue = opacitySlider.value;
            const environmentObjects = document.querySelectorAll('.tree, .building, .container, .bush'); // Example classes
            environmentObjects.forEach(object => {
                object.style.opacity = opacityValue; // Apply opacity to each object
            });
        });

        // Max FPS control label
        const fpsLabel = document.createElement('label');
        fpsLabel.innerText = 'Set Max FPS: ';
        guiContainer.appendChild(fpsLabel);

        // Create FPS slider
        const fpsSlider = document.createElement('input');
        fpsSlider.type = 'range';
        fpsSlider.min = '0';
        fpsSlider.max = '500';
        fpsSlider.step = '1';
        fpsSlider.value = '60'; // Default FPS
        guiContainer.appendChild(fpsSlider);

        // Event listener for FPS slider
        fpsSlider.addEventListener('input', function () {
            // Set the max FPS based on slider value
            const fpsValue = fpsSlider.value;
            // Example FPS limiter (adjust as needed)
            document.querySelector('canvas').style['max-fps'] = fpsValue;
        });

        // Add Lock HUD checkbox (placed under the last slider)
        const lockHudLabel = document.createElement('label');
        lockHudLabel.innerText = 'Lock HUD in Place: ';
        guiContainer.appendChild(lockHudLabel);

        const lockHudCheckbox = document.createElement('input');
        lockHudCheckbox.type = 'checkbox';
        guiContainer.appendChild(lockHudCheckbox);

        // Draggable HUD logic
        let isDragging = false;
        let offsetX, offsetY;
        let isHudLocked = false;

        // Make the GUI container draggable (if not locked)
        guiContainer.addEventListener('mousedown', (e) => {
            if (!isHudLocked) {
                isDragging = true;
                offsetX = e.clientX - guiContainer.offsetLeft;
                offsetY = e.clientY - guiContainer.offsetTop;
            }
        });

        document.addEventListener('mousemove', (e) => {
            if (isDragging && !isHudLocked) {
                guiContainer.style.left = `${e.clientX - offsetX}px`;
                guiContainer.style.top = `${e.clientY - offsetY}px`;
            }
        });

        document.addEventListener('mouseup', () => {
            isDragging = false;
        });

        // Listen for lock/unlock checkbox change
        lockHudCheckbox.addEventListener('change', function () {
            isHudLocked = lockHudCheckbox.checked; // Lock or unlock the HUD based on checkbox state
        });
    }

    // Toggle GUI visibility with "L" key
    let guiVisible = false;
    function toggleGUI() {
        if (!guiVisible) {
            createGUI(); // Create the GUI if not already created
        }
        guiVisible = !guiVisible;
        guiContainer.style.display = guiVisible ? 'block' : 'none'; // Show/hide the container
    }

    // Keybind for showing/hiding the GUI
    window.addEventListener('keydown', (event) => {
        if (event.key.toLowerCase() === 'l') {
            toggleGUI();
        }
    });
})();
(function () {
    let locked = false;

    // 🧹 Remove any existing HUD first
    const existingHud = document.getElementById('customHud');
    if (existingHud) {
        existingHud.remove();
    }

    // Create the HUD
    const hud = document.createElement('div');
    hud.id = 'customHud'; // Unique ID to detect duplicates
    Object.assign(hud.style, {
        position: 'fixed',
        top: '50%',
        left: '50%',
        transform: 'translate(-50%, -50%)',
        backgroundColor: 'rgba(0, 0, 0, 0.8)',
        color: 'white',
        padding: '20px',
        borderRadius: '10px',
        zIndex: '9999',
        cursor: 'move',
        display: 'block'
    });
    document.body.appendChild(hud);

    // Draggable logic
    let isDragging = false;
    let offsetX = 0, offsetY = 0;

    hud.addEventListener('mousedown', (e) => {
        if (!locked) {
            isDragging = true;
            offsetX = e.clientX - hud.offsetLeft;
            offsetY = e.clientY - hud.offsetTop;
            document.addEventListener('mousemove', onMouseMove);
        }
    });

    document.addEventListener('mouseup', () => {
        isDragging = false;
        document.removeEventListener('mousemove', onMouseMove);
    });

    function onMouseMove(e) {
        if (isDragging && !locked) {
            hud.style.left = `${e.clientX - offsetX}px`;
            hud.style.top = `${e.clientY - offsetY}px`;
        }
    }

    // HUD content
    const naturalFeaturesElement = document.createElement('div');
    const featuresElement = document.createElement('div');
    const quickSwitchElement = document.createElement('div');
    const fpsElement = document.createElement('div');
    const pingElement = document.createElement('div');
    const devInfoElement = document.createElement('div');
    const disableTextElement = document.createElement('div');

    naturalFeaturesElement.textContent = 'L = Natural Game Features';
    featuresElement.textContent = 'T = Key Features 👀';
    quickSwitchElement.textContent = 'O = Quick Switch Feature';
    fpsElement.textContent = 'FPS Rate: Adjusts every 100ms';
    pingElement.textContent = 'Ping: Developing at the moment';
    devInfoElement.textContent = 'This client is still under development. Report bugs to canadian100.0 on Discord.';
    disableTextElement.textContent = "Press 'n' to disable this HUD";

    hud.appendChild(naturalFeaturesElement);
    hud.appendChild(featuresElement);
    hud.appendChild(quickSwitchElement);
    hud.appendChild(fpsElement);
    hud.appendChild(pingElement);
    hud.appendChild(devInfoElement);
    hud.appendChild(disableTextElement);

    // Lock checkbox
    const lockCheckbox = document.createElement('input');
    lockCheckbox.type = 'checkbox';
    lockCheckbox.id = 'lockHudCheckbox';
    const lockLabel = document.createElement('label');
    lockLabel.textContent = ' Lock HUD in Place';
    lockLabel.setAttribute('for', 'lockHudCheckbox');
    hud.appendChild(lockCheckbox);
    hud.appendChild(lockLabel);

    lockCheckbox.addEventListener('change', () => {
        locked = lockCheckbox.checked;
    });

    // FPS tracking
    let fps = 0;
    let frames = 0;
    let lastTime = performance.now();

    function updateFPS() {
        const currentTime = performance.now();
        frames++;
        if (currentTime - lastTime >= 100) {
            fps = frames;
            frames = 0;
            lastTime = currentTime;
            fpsElement.textContent = `FPS Rate: Adjusts every 100ms - ${fps}`;
        }
    }

    setInterval(updateFPS, 100);

    // Toggle HUD visibility with 'n'
    window.addEventListener('keydown', (e) => {
        if (e.key.toLowerCase() === 'n') {
            hud.style.display = hud.style.display === 'none' ? 'block' : 'none';
        }
    });
})();
(function () {
    let isHudVisible = false;
    let isLocked = false;
    let switchDelay = 1000;
    let singleShotEnabled = false;
    let outOfAmmoEnabled = false;

    // Create HUD
    const hud = document.createElement('div');
    Object.assign(hud.style, {
        position: 'fixed',
        left: '50%',
        top: '50%',
        transform: 'translate(-50%, -50%)',
        background: 'rgba(0,0,0,0.8)',
        color: '#fff',
        padding: '15px',
        borderRadius: '10px',
        maxWidth: '180px',
        zIndex: 9999,
        fontSize: '12px',
        userSelect: 'none',
        flexDirection: 'column',
        gap: '8px',
        cursor: 'move',
        display: 'none'
    });
    hud.style.display = 'none';
    hud.style.display = 'flex';
    hud.style.display = 'none'; // Make sure it starts hidden
    document.body.appendChild(hud);

    // Delay Slider
    const delayLabel = document.createElement('label');
    delayLabel.textContent = 'Switch Delay (ms)';
    const delaySlider = document.createElement('input');
    delaySlider.type = 'range';
    delaySlider.min = 100;
    delaySlider.max = 3000;
    delaySlider.step = 100;
    delaySlider.value = switchDelay;
    delaySlider.addEventListener('input', () => {
        switchDelay = parseInt(delaySlider.value);
    });

    // Checkbox: After Single Shot
    const singleShotBox = document.createElement('input');
    singleShotBox.type = 'checkbox';
    singleShotBox.addEventListener('change', () => {
        singleShotEnabled = singleShotBox.checked;
    });
    const singleShotLabel = document.createElement('label');
    singleShotLabel.textContent = 'After Single Shot';
    singleShotLabel.prepend(singleShotBox);

    // Checkbox: Out of Ammo
    const outOfAmmoBox = document.createElement('input');
    outOfAmmoBox.type = 'checkbox';
    outOfAmmoBox.addEventListener('change', () => {
        outOfAmmoEnabled = outOfAmmoBox.checked;
    });
    const outOfAmmoLabel = document.createElement('label');
    outOfAmmoLabel.textContent = 'Out of Ammo';
    outOfAmmoLabel.prepend(outOfAmmoBox);

    // Checkbox: Lock HUD
    const lockBox = document.createElement('input');
    lockBox.type = 'checkbox';
    lockBox.addEventListener('change', () => {
        isLocked = lockBox.checked;
    });
    const lockLabel = document.createElement('label');
    lockLabel.textContent = 'Lock HUD';
    lockLabel.prepend(lockBox);

    // Append to HUD
    hud.appendChild(delayLabel);
    hud.appendChild(delaySlider);
    hud.appendChild(singleShotLabel);
    hud.appendChild(outOfAmmoLabel);
    hud.appendChild(lockLabel);

    // Drag logic
    let isDragging = false, offsetX = 0, offsetY = 0;
    hud.addEventListener('mousedown', (e) => {
        if (isLocked) return;
        isDragging = true;
        offsetX = e.clientX - hud.offsetLeft;
        offsetY = e.clientY - hud.offsetTop;
    });
    document.addEventListener('mousemove', (e) => {
        if (isDragging && !isLocked) {
            hud.style.left = `${e.clientX - offsetX}px`;
            hud.style.top = `${e.clientY - offsetY}px`;
        }
    });
    document.addEventListener('mouseup', () => isDragging = false);

    // Toggle HUD with 'O'
    window.addEventListener('keydown', (e) => {
        if (e.key.toLowerCase() === 'o') {
            isHudVisible = !isHudVisible;
            hud.style.display = isHudVisible ? 'flex' : 'none';
        }
    });

    // Dummy game interaction simulation (replace with real logic)
    function switchWeaponSlot() {
        const slots = [1, 2, 3].filter(slot => true); // All usable
        let currentSlot = getCurrentSlot(); // Replace this
        let nextIndex = (slots.indexOf(currentSlot) + 1) % slots.length;
        simulateKeyPress(slots[nextIndex].toString());
    }

    function getCurrentSlot() {
        return 1; // Replace with actual game detection
    }

    function simulateKeyPress(key) {
        document.dispatchEvent(new KeyboardEvent('keydown', { key }));
    }

    function switchWeaponSlotWithDelay() {
        setTimeout(() => switchWeaponSlot(), switchDelay);
    }

    // Trigger test loop (replace with actual game events)
    setInterval(() => {
        if (singleShotEnabled || outOfAmmoEnabled) {
            switchWeaponSlotWithDelay();
        }
    }, 3000);
})();