Vortex Forge Web Client V1.2

Vortex Forge Web Client with Sniper Mode

目前為 2025-01-21 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Vortex Forge Web Client V1.2
// @namespace    http://tampermonkey.net/
// @version      2.2
// @description  Vortex Forge Web Client with Sniper Mode
// @author       NOOB
// @match        https://deadshot.io/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    let featuresEnabled = true;
    let sniperModeEnabled = false;
    let fireworkInterval = null;
    let kKeyInterval = null;
    let isRightMousePressed = false;
    let spacebarLockEnabled = false;

    const newSettingsContent = `
    <div class="setting toggle" style="margin-top: 30px; padding: 9px 30px;">
        <p style="font-size: 21px;">Sniper Mode</p>
        <label>
            <input id="vfSniperMode" class="checkbox" type="checkbox">
            <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>`;

    //For new updates,lock spacebar option toggle
    function showToast(message) {
        const toast = document.createElement('div');
        toast.innerText = message;
        toast.style.position = 'fixed';
        toast.style.bottom = '20px';
        toast.style.right = '20px';
        toast.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
        toast.style.color = 'white';
        toast.style.padding = '10px 20px';
        toast.style.borderRadius = '5px';
        toast.style.fontSize = '14px';
        toast.style.zIndex = '10000';
        toast.style.opacity = '0';
        toast.style.transition = 'opacity 0.5s';

        document.body.appendChild(toast);

        setTimeout(() => (toast.style.opacity = '1'), 50);
        setTimeout(() => {
            toast.style.opacity = '0';
            setTimeout(() => toast.remove(), 500);
        }, 2000);
    }

    document.addEventListener('keydown', (e) => {
        if (e.key === 'Control') {
            spacebarLockEnabled = !spacebarLockEnabled;
            if (spacebarLockEnabled) {
                showToast('Spacebar lock is ON');
            } else {
                showToast('Spacebar lock is OFF');
            }
        }
    });

    document.addEventListener('keydown', (e) => {
        if (spacebarLockEnabled && (e.key === ' ' || e.code === 'Space')) {
            e.stopPropagation();

            const isTyping = e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA';
            if (!isTyping) {
                e.preventDefault();
            }
        }
    });

    //Make space by removing left handed mode(rubbish)
    function removeLeftHandedSetting() {
        const leftHandedDiv = document.querySelector('.setting.toggle input#lefthand')?.closest('.setting.toggle');
        if (leftHandedDiv) {
            leftHandedDiv.remove();
            console.log("Left-Handed setting removed.");
        }
    }

    function addCustomSettingsToTop() {
        const settingsDiv = document.getElementById('settingsDiv');
        if (settingsDiv && !document.getElementById('vfSniperMode')) {
            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) {
                removeLeftHandedSetting();
                addCustomSettingsToTop();
                setupSniperModeToggle();
                setupVortexForgeModeToggle();
                clearInterval(retryInterval);
            }
        }, 500);
    }

    function setupSniperModeToggle() {
        const sniperModeCheckbox = document.getElementById('vfSniperMode');
        if (sniperModeCheckbox) {
            sniperModeCheckbox.addEventListener('change', (event) => {
                sniperModeEnabled = event.target.checked;
            });
        }
    }

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

    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);
        }
    }

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

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

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

        if (e.button === 2) { 
            if (!isRightMousePressed) {
                isRightMousePressed = true;

                if (!sniperModeEnabled) {
                    startKKeyPress();
                }
            }
        }
    });

    document.addEventListener('mouseup', (e) => {
        if (e.button === 2) { 
            if (sniperModeEnabled) {
                startShooting();
            }else{
                stopKKeyPress();
            }

            isRightMousePressed = false;
        }
    });

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