Greasy Fork

Vortex Forge Web Client V1.0

Vortex Forge Web Client

目前为 2024-12-18 提交的版本。查看 最新版本

// ==UserScript==
// @name         Vortex Forge Web Client V1.0
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Vortex Forge Web Client
// @author       NOOB
// @match        https://deadshot.io/*
// @grant        none
// ==/UserScript==

//Copyright ©2024 Vortex Forge.Unauthorized modifications strictly prohibited

(function () {
    'use strict';

    let featuresEnabled = true;
    let crosshairColor = 'green';
    let kKeyInterval = null;
    let isRightMousePressed = false;
    let snowfallEnabled = true;
    let snowflakeInterval;

    const newSettingsContent =`

    <div class="setting toggle" style="margin-top: 80px; padding: 9px 30px;">
            <p style="font-size: 21px;">Seasonal Update</p>
            <label>
                <input id="vfswapper" class="checkbox" type="checkbox" checked="">
                <span></span>
            </label>
        </div>

    <div class="setting toggle" style="padding: 9px 30px; background-color: rgba(255, 255, 255, 0.03);">
            <p style="font-size: 21px;">VF Mode</p>
            <label>
                <input id="vfsettings" class="checkbox" type="checkbox" checked="">
                <span></span>
            </label>
        </div>
    `
    ;

    function addCustomSettingsToTop() {
        const settingsDiv = document.getElementById('settingsDiv');
        if (settingsDiv && !document.getElementById('vfsettings')) {
            const customDiv = document.createElement('div');
            customDiv.innerHTML = newSettingsContent;

            settingsDiv.insertBefore(customDiv, settingsDiv.firstChild);
        }
    }

    function waitForSettingsDiv() {
        const retryInterval = setInterval(() => {
            const settingsDiv = document.getElementById('settingsDiv');
            if (settingsDiv) {
                addCustomSettingsToTop();
                setupVortexForgeModeToggle();
                setupSnowfallToggle();
                clearInterval(retryInterval);
            }
        }, 500);
    }

    function setupVortexForgeModeToggle() {
        const vfCheckbox = document.getElementById('vfsettings');
        if (vfCheckbox) {
            vfCheckbox.addEventListener('change', (event) => {
                featuresEnabled = !featuresEnabled;
                toggleFeatures(featuresEnabled);
            });
        }
    }

    function setupSnowfallToggle() {
        const swapperCheckbox = document.getElementById('vfswapper');
        if (swapperCheckbox) {
            swapperCheckbox.addEventListener('change', (event) => {
                snowfallEnabled = event.target.checked;
                toggleSnowfall(snowfallEnabled);
            });
        }
    }

    function toggleFeatures(enabled) {
        if (!enabled) {
            stopKKeyPress();
            isRightMousePressed = false;
        }
    }

    function startKKeyPress() {
        if (!kKeyInterval) {
            kKeyInterval = setInterval(() => {
                const kKeyEvent = new KeyboardEvent('keydown', {
                    key: 'K',
                    code: 'KeyK',
                    keyCode: 75,
                    which: 75,
                    bubbles: true,
                    cancelable: true,
                });
                document.dispatchEvent(kKeyEvent);
            }, 100);
        }
    }

    function stopKKeyPress() {
        if (kKeyInterval) {
            clearInterval(kKeyInterval);
            kKeyInterval = null;

            const kKeyUpEvent = new KeyboardEvent('keyup', {
                key: 'K',
                code: 'KeyK',
                keyCode: 75,
                which: 75,
                bubbles: true,
                cancelable: true,
            });
            document.dispatchEvent(kKeyUpEvent);
        }
    }

    document.addEventListener('mousedown', (e) => {
        if (!featuresEnabled) return;

        if (e.button === 2) {
            crosshairColor = 'red';

            if (!isRightMousePressed) {
                isRightMousePressed = true;
                startKKeyPress();
            }
        }
    });

    document.addEventListener('mouseup', (e) => {
        if (e.button === 2) {
            crosshairColor = 'green';

            stopKKeyPress();
            isRightMousePressed = false;
        }
    });

    function createSnowfallEffect() {
        const snowContainer = document.createElement('div');
        snowContainer.id = 'snow-container';
        snowContainer.style.position = 'fixed';
        snowContainer.style.pointerEvents = 'none';
        snowContainer.style.top = '0';
        snowContainer.style.left = '0';
        snowContainer.style.width = '100%';
        snowContainer.style.height = '100%';
        snowContainer.style.zIndex = '9999';
        document.body.appendChild(snowContainer);

        snowflakeInterval = setInterval(() => {
            const snowflake = document.createElement('div');
            snowflake.className = 'snowflake';
            snowflake.style.position = 'absolute';
            snowflake.style.top = '-10px';
            snowflake.style.left = Math.random() * window.innerWidth + 'px';
            snowflake.style.width = Math.random() * 5 + 5 + 'px';
            snowflake.style.height = snowflake.style.width;
            snowflake.style.backgroundColor = 'white';
            snowflake.style.borderRadius = '50%';
            snowflake.style.opacity = Math.random();
            snowflake.style.animation = `fall ${Math.random() * 3 + 2}s linear infinite`;

            snowContainer.appendChild(snowflake);

            setTimeout(() => {
                snowflake.remove();
            }, 5000);
        }, 100);

        const style = document.createElement('style');
        style.innerHTML = `
            @keyframes fall {
                to {
                    transform: translateY(${window.innerHeight}px);
                }
            }
        `;
        document.head.appendChild(style);
    }

    function toggleSnowfall(enabled) {
        const snowContainer = document.getElementById('snow-container');
        if (enabled) {
            if (!snowContainer) {
                createSnowfallEffect();
            }
        } else {
            if (snowContainer) {
                snowContainer.remove();
                clearInterval(snowflakeInterval);
            }
        }
    }

    window.addEventListener('load', () => {
        waitForSettingsDiv();
        if (snowfallEnabled) {
            createSnowfallEffect();
        }
    });
})();