Wormax.IO Zoom [WORKS ONLY ON THORIUM] [Stutter fix]

Stutter and respawn fix!

Verze ze dne 13. 07. 2025. Zobrazit nejnovější verzi.

// ==UserScript==
// @name         Wormax.IO Zoom [WORKS ONLY ON THORIUM] [Stutter fix]
// @namespace    http://tampermonkey.net/
// @version      3.4
// @description  Stutter and respawn fix! 
// @author       AdamStorme
// @match        *://*.wormax.io/*
// @grant        none
// @license      MIT
// ==/UserScript==
// ==UserScript==
// @name         Wormax.IO Zoom (Final Fix - Stable, Stutter-Free, Respawn-Safe)
// @namespace    http://tampermonkey.net/
// @version      3.6
// @description  Smooth zoom for Wormax.IO, rehooks after death, avoids lag, and uses zoom property trapping that actually works every time, on every browser/client reliably.
// @author       AdamStorme
// @match        *://*.wormax.io/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
    const script = document.createElement('script');
    script.textContent = '(' + function () {
        let zoomTarget = 1.0;
        let zoomCurrent = 1.0;
        let currentCamera = null;
        let currentController = null;

        function findCameraController() {
            const stack = [window];
            const visited = new WeakSet();

            while (stack.length) {
                const obj = stack.pop();
                if (!obj || typeof obj !== 'object' || visited.has(obj)) continue;
                visited.add(obj);

                for (const key in obj) {
                    try {
                        const val = obj[key];
                        if (
                            val &&
                            typeof val === 'object' &&
                            val.camera &&
                            typeof val.camera.zoom === 'number' &&
                            'updateZoom' in val &&
                            'follow' in val
                        ) {
                            return val;
                        }
                        if (val && typeof val === 'object') {
                            stack.push(val);
                        }
                    } catch {}
                }
            }
            return null;
        }

        function isZoomGetterWorking(camera) {
            const descriptor = Object.getOwnPropertyDescriptor(camera, 'zoom');
            return descriptor && typeof descriptor.get === 'function' && descriptor.get.toString().includes('zoomCurrent');
        }

        function patchZoomProperty(camera) {
            try {
                Object.defineProperty(camera, 'zoom', {
                    get: () => zoomCurrent,
                    set: (v) => {
                        zoomTarget = Math.max(0.1, Math.min(5.0, v));
                    },
                    configurable: true
                });
                console.log('[ZoomMod] Patched camera.zoom');
            } catch (e) {
                console.warn('[ZoomMod] Zoom patch failed:', e);
            }
        }

        function animationLoop() {
            const step = () => {
                const controller = findCameraController();

                if (
                    controller &&
                    controller.camera &&
                    typeof controller.camera.zoom === 'number'
                ) {
                    if (controller !== currentController) {
                        currentController = controller;
                        currentCamera = controller.camera;
                        controller.updateZoom = false;
                        console.log('[ZoomMod] Rehooked new camera');
                    }

                    // Repatch if camera object changed or lost our trap
                    if (currentCamera !== controller.camera || !isZoomGetterWorking(controller.camera)) {
                        currentCamera = controller.camera;
                        patchZoomProperty(currentCamera);
                    }

                    // Smooth zoom update
                    const diff = zoomTarget - zoomCurrent;
                    zoomCurrent += diff * 0.15;
                    if (Math.abs(diff) < 0.0005) zoomCurrent = zoomTarget;

                    currentCamera.update?.();
                }

                requestAnimationFrame(step);
            };
            requestAnimationFrame(step);
        }

        function setupInput() {
            window.addEventListener('wheel', (e) => {
                const step = e.altKey ? 0.1 : e.shiftKey ? 1.0 : 0.2;
                zoomTarget = Math.max(0.1, Math.min(5.0, zoomTarget + (e.deltaY > 0 ? step : -step)));
                e.preventDefault();
            }, { passive: false });

            document.addEventListener('keydown', (e) => {
                if (e.key.toLowerCase() === 'r') {
                    zoomTarget = 1.0;
                    console.log('[ZoomMod] Zoom reset');
                }
            });
        }

        setupInput();
        animationLoop();
    } + ')();';

    document.body.appendChild(script);
})();
长期地址
遇到问题?请前往 GitHub 提 Issues。