Wormax.IO Zoom (Fixed client-side issues)

Enables smooth zoom with mouse wheel Wormax.IO.

Від 13.07.2025. Дивіться остання версія.

// ==UserScript==
// @name         Wormax.IO Zoom (Fixed client-side issues)
// @namespace    http://tampermonkey.net/
// @version      1.6
// @description  Enables smooth zoom with mouse wheel Wormax.IO.
// @author       AdamStorme
// @match        *://*.wormax.io/*
// @grant        none
// @license MIT
// ==/UserScript==

(function () {
    'use strict';

    let zoomTarget = 1.0;
    let cameraController = 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 (e) {}
            }
        }
        return null;
    }

    function startZoomControlLoop() {
        const cam = cameraController.camera;
        cameraController.updateZoom = false;
        console.log('[ZoomMod] Zoom control enabled');

        const zoomStep = () => {
            const diff = zoomTarget - cam.zoom;
            cam.zoom += diff * 0.05;
            requestAnimationFrame(zoomStep);
        };
        requestAnimationFrame(zoomStep);
    }

    function setupUserInput() {
        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');
            }
        });
    }

    function waitForGameInit() {
        const interval = setInterval(() => {
            const ctrl = findCameraController();
            if (ctrl && ctrl.camera && typeof ctrl.camera.zoom === 'number') {
                clearInterval(interval);
                cameraController = ctrl;
                setupUserInput();
                startZoomControlLoop();
            }
        }, 1000);
    }

    waitForGameInit();
})();
长期地址
遇到问题?请前往 GitHub 提 Issues。