Wormax.io Smooth Movement Fix

Lag Fix for Wormax.IO

当前为 2025-07-08 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Wormax.io Smooth Movement Fix
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  Lag Fix for Wormax.IO
// @author       AdamStorme
// @match        *://wormax.io/*
// @match        *://*.wormax.io/*
// @grant        none
// @run-at       document-start
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // GWT-style obfuscated variables
    var cggl$smoothFix = {};
    var cbgm$interpolation = {};
    var nesg$frameStabilizer = {};
    var cgguc$performance = {};
    var ji2$config = {};
    var jl$utils = {};

    // Obfuscated configuration object
    ji2$config.smoothConfig = {
        a: true,  // interpolationEnabled
        b: 60,    // frameRateTarget
        c: 0.8,   // smoothingFactor
        d: true,  // lagCompensation
        e: true,  // predictionEnabled
        f: 100,   // maxPredictionTime
        g: false  // debugMode
    };

    // Obfuscated performance variables
    var frameCount_0 = 0;
    var lastTimeStamp_0 = 0;
    var deltaTimeHistory_0 = [];
    var avgDeltaTime_0 = 16.67;

    // GWT-style function definitions
    cggl$smoothFix.$clinit_SmoothMovement = function $clinit_SmoothMovement(){
        cggl$smoothFix.$clinit_SmoothMovement = function(){};
        console.log('[SMF] $clinit_SmoothMovement initialized');
    };

    cbgm$interpolation.$init_interpolationSystem = function $init_interpolationSystem(){
        this.positions_0 = new Map();
        this.velocities_0 = new Map();
    };

    cbgm$interpolation.updatePosition_0 = function updatePosition_0(entityId_0, newPos_0, timestamp_0){
        if (!this.positions_0.has(entityId_0)) {
            this.positions_0.set(entityId_0, {
                current_0: {x_0: newPos_0.x_0, y_0: newPos_0.y_0},
                target_0: {x_0: newPos_0.x_0, y_0: newPos_0.y_0},
                lastUpdate_0: timestamp_0
            });
            return;
        }

        var posData_0 = this.positions_0.get(entityId_0);
        posData_0.current_0 = {x_0: posData_0.target_0.x_0, y_0: posData_0.target_0.y_0};
        posData_0.target_0 = {x_0: newPos_0.x_0, y_0: newPos_0.y_0};
        posData_0.lastUpdate_0 = timestamp_0;
    };

    cbgm$interpolation.interpolate_0 = function interpolate_0(entityId_0, currentTime_0){
        var posData_0 = this.positions_0.get(entityId_0);
        if (!posData_0) return null;

        var timeDiff_0 = currentTime_0 - posData_0.lastUpdate_0;
        var factor_0 = Math.min(timeDiff_0 / avgDeltaTime_0, 1) * ji2$config.smoothConfig.c;

        return {
            x_0: posData_0.current_0.x_0 + (posData_0.target_0.x_0 - posData_0.current_0.x_0) * factor_0,
            y_0: posData_0.current_0.y_0 + (posData_0.target_0.y_0 - posData_0.current_0.y_0) * factor_0
        };
    };

    nesg$frameStabilizer.$init_frameStabilizer = function $init_frameStabilizer(){
        this.lastTime_0 = 0;
        this.frameInterval_0 = 1000 / ji2$config.smoothConfig.b;
    };

    nesg$frameStabilizer.shouldRender_0 = function shouldRender_0(currentTime_0){
        if (currentTime_0 - this.lastTime_0 >= this.frameInterval_0) {
            this.lastTime_0 = currentTime_0;
            return true;
        }
        return false;
    };

    // Obfuscated RAF hook
    jl$utils.hookRequestAnimationFrame_0 = function hookRequestAnimationFrame_0(){
        var originalRAF_0 = window.requestAnimationFrame;
        window.requestAnimationFrame = function(callback_0) {
            return originalRAF_0.call(this, function(timestamp_0) {
                var deltaTime_0 = timestamp_0 - lastTimeStamp_0;
                lastTimeStamp_0 = timestamp_0;

                deltaTimeHistory_0.push(deltaTime_0);
                if (deltaTimeHistory_0.length > 10) {
                    deltaTimeHistory_0.shift();
                }
                avgDeltaTime_0 = deltaTimeHistory_0.reduce(function(a, b) { return a + b; }, 0) / deltaTimeHistory_0.length;

                if (nesg$frameStabilizer.shouldRender_0(timestamp_0)) {
                    frameCount_0++;
                    callback_0(timestamp_0);
                }
            });
        };
    };

    // Obfuscated canvas enhancement
    cgguc$performance.enhanceCanvasRendering_0 = function enhanceCanvasRendering_0(){
        var canvas_0 = document.querySelector('canvas');
        if (!canvas_0) {
            setTimeout(cgguc$performance.enhanceCanvasRendering_0, 100);
            return;
        }

        var ctx_0 = canvas_0.getContext('2d');
        if (!ctx_0) return;

        ctx_0.imageSmoothingEnabled = true;
        if (ctx_0.imageSmoothingQuality) {
            ctx_0.imageSmoothingQuality = 'high';
        }

        // Hook clearRect for motion blur effect
        var originalClearRect_0 = ctx_0.clearRect;
        ctx_0.clearRect = function() {
            ctx_0.globalAlpha = 0.95;
            ctx_0.fillStyle = 'rgba(0,0,0,0.05)';
            ctx_0.fillRect(0, 0, canvas_0.width, canvas_0.height);
            ctx_0.globalAlpha = 1.0;
            return originalClearRect_0.apply(this, arguments);
        };

        console.log('[SMF] Canvas rendering enhanced');
    };

    // Obfuscated movement prediction
    cggl$smoothFix.movementPredictor_0 = {
        predictions_0: new Map(),

        predict_0: function(entityId_0, position_0, velocity_0, deltaTime_0) {
            if (!ji2$config.smoothConfig.e) return position_0;

            var prediction_0 = {
                x_0: position_0.x_0 + velocity_0.x_0 * deltaTime_0,
                y_0: position_0.y_0 + velocity_0.y_0 * deltaTime_0
            };

            this.predictions_0.set(entityId_0, prediction_0);
            return prediction_0;
        },

        getPrediction_0: function(entityId_0) {
            return this.predictions_0.get(entityId_0);
        }
    };

    // Obfuscated performance monitor
    cgguc$performance.performanceMonitor_0 = {
        start_0: function() {
            setInterval(function() {
                if (ji2$config.smoothConfig.g) {
                    console.log('[SMF] FPS: ' + Math.round(frameCount_0) + ', Avg Delta: ' + avgDeltaTime_0.toFixed(2) + 'ms');
                }
                frameCount_0 = 0;
            }, 1000);
        }
    };

    // Obfuscated input smoother
    jl$utils.inputSmoother_0 = {
        lastInputTime_0: 0,
        inputBuffer_0: [],

        smoothInput_0: function(inputEvent_0) {
            var currentTime_0 = performance.now();

            this.inputBuffer_0.push({
                event_0: inputEvent_0,
                timestamp_0: currentTime_0
            });

            this.inputBuffer_0 = this.inputBuffer_0.filter(function(input_0) {
                return currentTime_0 - input_0.timestamp_0 < 100;
            });

            return this.inputBuffer_0.length > 1;
        }
    };

    // Main initialization function with GWT-style naming
    cggl$smoothFix.initialize_SmoothMovement = function initialize_SmoothMovement(){
        cggl$smoothFix.$clinit_SmoothMovement();

        // Initialize subsystems
        cbgm$interpolation.$init_interpolationSystem();
        nesg$frameStabilizer.$init_frameStabilizer();

        // Hook systems
        jl$utils.hookRequestAnimationFrame_0();
        cgguc$performance.enhanceCanvasRendering_0();
        cgguc$performance.performanceMonitor_0.start_0();

        // Keyboard event handler with obfuscated key handling
        document.addEventListener('keydown', function(e_0) {
            if (e_0.ctrlKey && e_0.altKey) {
                switch(e_0.key.toLowerCase()) {
                    case 'i':
                        ji2$config.smoothConfig.a = !ji2$config.smoothConfig.a;
                        console.log('[SMF] Interpolation: ' + (ji2$config.smoothConfig.a ? 'ON' : 'OFF'));
                        e_0.preventDefault();
                        break;
                    case 'p':
                        ji2$config.smoothConfig.e = !ji2$config.smoothConfig.e;
                        console.log('[SMF] Prediction: ' + (ji2$config.smoothConfig.e ? 'ON' : 'OFF'));
                        e_0.preventDefault();
                        break;
                    case 'd':
                        ji2$config.smoothConfig.g = !ji2$config.smoothConfig.g;
                        console.log('[SMF] Debug mode: ' + (ji2$config.smoothConfig.g ? 'ON' : 'OFF'));
                        e_0.preventDefault();
                        break;
                }
            }
        });

        console.log('[SMF] Smooth movement system initialized!');
        console.log('[SMF] Controls: Ctrl+Alt+I (interpolation), Ctrl+Alt+P (prediction), Ctrl+Alt+D (debug)');
    };

    // Advanced GWT-style game object detection and hooking
    cggl$smoothFix.gameObjectHooker_0 = {
        hookedObjects_0: new Set(),

        scanForGameObjects_0: function() {
            var self_0 = this;

            // Scan window object for potential game objects
            function scanObject_0(obj_0, depth_0) {
                if (depth_0 > 3 || !obj_0) return;

                try {
                    for (var key_0 in obj_0) {
                        if (typeof obj_0[key_0] === 'object' && obj_0[key_0] !== null) {
                            // Look for snake-like objects with GWT naming patterns
                            if (self_0.isGameObject_0(obj_0[key_0])) {
                                self_0.hookGameObject_0(obj_0[key_0], key_0);
                            }

                            if (depth_0 < 2) {
                                scanObject_0(obj_0[key_0], depth_0 + 1);
                            }
                        }
                    }
                } catch (e_0) {
                    // Ignore access errors
                }
            }

            scanObject_0(window, 0);
        },

        isGameObject_0: function(obj_0) {
            // Check for common game object properties with obfuscated names
            return (obj_0.hasOwnProperty('currentSpeed') ||
                    obj_0.hasOwnProperty('position_0') ||
                    obj_0.hasOwnProperty('x_0') && obj_0.hasOwnProperty('y_0') ||
                    obj_0.hasOwnProperty('segments') ||
                    obj_0.hasOwnProperty('direction_0') ||
                    obj_0.hasOwnProperty('lastTickPosition'));
        },

        hookGameObject_0: function(obj_0, objKey_0) {
            if (this.hookedObjects_0.has(obj_0)) return;

            this.hookedObjects_0.add(obj_0);

            // Hook movement-related methods if they exist
            if (typeof obj_0.playTill === 'function') {
                this.hookPlayTill_0(obj_0);
            }

            if (typeof obj_0.moveTail === 'function') {
                this.hookMoveTail_0(obj_0);
            }

            if (ji2$config.smoothConfig.g) {
                console.log('[SMF] Hooked game object: ' + objKey_0);
            }
        },

        hookPlayTill_0: function(obj_0) {
            var originalPlayTill_0 = obj_0.playTill;
            obj_0.playTill = function(till_0) {
                // Apply smooth movement interpolation
                if (ji2$config.smoothConfig.a && this.lastTickPosition) {
                    var entityId_0 = this.id_0 || Math.random();
                    var currentPos_0 = {
                        x_0: this.lastTickPosition.x_0,
                        y_0: this.lastTickPosition.y_0
                    };

                    cbgm$interpolation.updatePosition_0(entityId_0, currentPos_0, performance.now());
                }

                return originalPlayTill_0.call(this, till_0);
            };
        },

        hookMoveTail_0: function(obj_0) {
            var originalMoveTail_0 = obj_0.moveTail;
            obj_0.moveTail = function(dt_0, avgSpeedPerMs_0) {
                // Apply smoothing to tail movement
                if (ji2$config.smoothConfig.a) {
                    dt_0 = dt_0 * ji2$config.smoothConfig.c;
                }

                return originalMoveTail_0.call(this, dt_0, avgSpeedPerMs_0);
            };
        }
    };

    // Network lag compensation system
    jl$utils.lagCompensator_0 = {
        latencyHistory_0: [],
        avgLatency_0: 50,

        measureLatency_0: function() {
            var startTime_0 = performance.now();

            // Hook into WebSocket or XMLHttpRequest to measure network latency
            if (window.WebSocket) {
                var originalSend_0 = WebSocket.prototype.send;
                WebSocket.prototype.send = function(data_0) {
                    var sendTime_0 = performance.now();

                    // Store send time for latency calculation
                    this._lastSendTime = sendTime_0;

                    return originalSend_0.call(this, data_0);
                };
            }
        },

        updateLatency_0: function(latency_0) {
            this.latencyHistory_0.push(latency_0);
            if (this.latencyHistory_0.length > 10) {
                this.latencyHistory_0.shift();
            }

            this.avgLatency_0 = this.latencyHistory_0.reduce(function(a, b) { return a + b; }, 0) / this.latencyHistory_0.length;
        },

        compensatePosition_0: function(position_0, velocity_0) {
            if (!ji2$config.smoothConfig.d) return position_0;

            var compensation_0 = this.avgLatency_0 / 1000;
            return {
                x_0: position_0.x_0 + velocity_0.x_0 * compensation_0,
                y_0: position_0.y_0 + velocity_0.y_0 * compensation_0
            };
        }
    };

    // GWT-style UI system
    cgguc$performance.uiSystem_0 = {
        panel_0: null,
        isVisible_0: false,

        createUI_0: function() {
            if (this.panel_0) return;

            // Create main panel with GWT-style styling
            this.panel_0 = document.createElement('div');
            this.panel_0.id = 'cggl$smoothFix$panel_0';
            this.panel_0.innerHTML = this.getUIHTML_0();
            this.panel_0.style.cssText = this.getUIStyles_0();

            document.body.appendChild(this.panel_0);
            this.bindEvents_0();
            this.updateUI_0();

            console.log('[SMF] UI system initialized');
        },

        getUIHTML_0: function() {
            return `
                <div class="smf-header">
                    <span class="smf-title">🐍 Wormax.io Smooth Movement</span>
                    <button class="smf-close" onclick="cgguc$performance.uiSystem_0.toggleUI_0()">×</button>
                </div>
                <div class="smf-content">
                    <div class="smf-section">
                        <h3>🎯 Movement Settings</h3>
                        <div class="smf-control">
                            <label>
                                <input type="checkbox" id="smf-interpolation" ${ji2$config.smoothConfig.a ? 'checked' : ''}>
                                <span>Interpolation</span>
                            </label>
                            <span class="smf-desc">Smooth position transitions</span>
                        </div>
                        <div class="smf-control">
                            <label>
                                <input type="checkbox" id="smf-prediction" ${ji2$config.smoothConfig.e ? 'checked' : ''}>
                                <span>Lag Prediction</span>
                            </label>
                            <span class="smf-desc">Compensate for network lag</span>
                        </div>
                        <div class="smf-control">
                            <label>
                                <input type="checkbox" id="smf-lagcomp" ${ji2$config.smoothConfig.d ? 'checked' : ''}>
                                <span>Lag Compensation</span>
                            </label>
                            <span class="smf-desc">Advanced lag handling</span>
                        </div>
                    </div>

                    <div class="smf-section">
                        <h3>⚙️ Performance</h3>
                        <div class="smf-control">
                            <label>Target FPS:</label>
                            <input type="range" id="smf-fps" min="30" max="120" value="${ji2$config.smoothConfig.b}" step="10">
                            <span id="smf-fps-value">${ji2$config.smoothConfig.b}</span>
                        </div>
                        <div class="smf-control">
                            <label>Smoothing Factor:</label>
                            <input type="range" id="smf-smoothing" min="0.1" max="1.0" value="${ji2$config.smoothConfig.c}" step="0.1">
                            <span id="smf-smoothing-value">${ji2$config.smoothConfig.c}</span>
                        </div>
                        <div class="smf-control">
                            <label>Prediction Time:</label>
                            <input type="range" id="smf-predtime" min="50" max="200" value="${ji2$config.smoothConfig.f}" step="10">
                            <span id="smf-predtime-value">${ji2$config.smoothConfig.f}ms</span>
                        </div>
                    </div>

                    <div class="smf-section">
                        <h3>📊 Statistics</h3>
                        <div class="smf-stats">
                            <div class="smf-stat">
                                <span>Current FPS:</span>
                                <span id="smf-current-fps">--</span>
                            </div>
                            <div class="smf-stat">
                                <span>Avg Delta:</span>
                                <span id="smf-avg-delta">--</span>
                            </div>
                            <div class="smf-stat">
                                <span>Hooked Objects:</span>
                                <span id="smf-hooked-count">0</span>
                            </div>
                            <div class="smf-stat">
                                <span>Network Latency:</span>
                                <span id="smf-latency">--</span>
                            </div>
                        </div>
                    </div>

                    <div class="smf-section">
                        <h3>🔧 Debug</h3>
                        <div class="smf-control">
                            <label>
                                <input type="checkbox" id="smf-debug" ${ji2$config.smoothConfig.g ? 'checked' : ''}>
                                <span>Debug Mode</span>
                            </label>
                            <span class="smf-desc">Console logging</span>
                        </div>
                        <button class="smf-button" onclick="cgguc$performance.uiSystem_0.resetSettings_0()">Reset to Defaults</button>
                        <button class="smf-button" onclick="cgguc$performance.uiSystem_0.exportSettings_0()">Export Settings</button>
                    </div>
                </div>
                <div class="smf-footer">
                    <span>Press Ctrl+Shift+M to toggle | v1.0.0</span>
                </div>
            `;
        },

        getUIStyles_0: function() {
            return `
                position: fixed;
                top: 20px;
                right: 20px;
                width: 320px;
                background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
                border: 2px solid #0f3460;
                border-radius: 12px;
                box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
                font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
                font-size: 12px;
                color: #e94560;
                z-index: 999999;
                backdrop-filter: blur(10px);
                transition: all 0.3s ease;
                user-select: none;
            `;
        },

        bindEvents_0: function() {
            var self_0 = this;

            // Interpolation toggle
            document.getElementById('smf-interpolation').addEventListener('change', function(e_0) {
                ji2$config.smoothConfig.a = e_0.target.checked;
                console.log('[SMF] Interpolation: ' + (ji2$config.smoothConfig.a ? 'ON' : 'OFF'));
            });

            // Prediction toggle
            document.getElementById('smf-prediction').addEventListener('change', function(e_0) {
                ji2$config.smoothConfig.e = e_0.target.checked;
                console.log('[SMF] Prediction: ' + (ji2$config.smoothConfig.e ? 'ON' : 'OFF'));
            });

            // Lag compensation toggle
            document.getElementById('smf-lagcomp').addEventListener('change', function(e_0) {
                ji2$config.smoothConfig.d = e_0.target.checked;
                console.log('[SMF] Lag Compensation: ' + (ji2$config.smoothConfig.d ? 'ON' : 'OFF'));
            });

            // Debug mode toggle
            document.getElementById('smf-debug').addEventListener('change', function(e_0) {
                ji2$config.smoothConfig.g = e_0.target.checked;
                console.log('[SMF] Debug Mode: ' + (ji2$config.smoothConfig.g ? 'ON' : 'OFF'));
            });

            // FPS slider
            document.getElementById('smf-fps').addEventListener('input', function(e_0) {
                ji2$config.smoothConfig.b = parseInt(e_0.target.value);
                document.getElementById('smf-fps-value').textContent = ji2$config.smoothConfig.b;
                nesg$frameStabilizer.frameInterval_0 = 1000 / ji2$config.smoothConfig.b;
            });

            // Smoothing factor slider
            document.getElementById('smf-smoothing').addEventListener('input', function(e_0) {
                ji2$config.smoothConfig.c = parseFloat(e_0.target.value);
                document.getElementById('smf-smoothing-value').textContent = ji2$config.smoothConfig.c;
            });

            // Prediction time slider
            document.getElementById('smf-predtime').addEventListener('input', function(e_0) {
                ji2$config.smoothConfig.f = parseInt(e_0.target.value);
                document.getElementById('smf-predtime-value').textContent = ji2$config.smoothConfig.f + 'ms';
            });
        },

        toggleUI_0: function() {
            if (!this.panel_0) return;

            this.isVisible_0 = !this.isVisible_0;
            this.panel_0.style.display = this.isVisible_0 ? 'block' : 'none';
        },

        updateUI_0: function() {
            if (!this.panel_0) return;

            // Update statistics
            var currentFpsEl_0 = document.getElementById('smf-current-fps');
            var avgDeltaEl_0 = document.getElementById('smf-avg-delta');
            var hookedCountEl_0 = document.getElementById('smf-hooked-count');
            var latencyEl_0 = document.getElementById('smf-latency');

            if (currentFpsEl_0) currentFpsEl_0.textContent = Math.round(frameCount_0) + ' FPS';
            if (avgDeltaEl_0) avgDeltaEl_0.textContent = avgDeltaTime_0.toFixed(1) + 'ms';
            if (hookedCountEl_0) hookedCountEl_0.textContent = cggl$smoothFix.gameObjectHooker_0.hookedObjects_0.size;
            if (latencyEl_0) latencyEl_0.textContent = jl$utils.lagCompensator_0.avgLatency_0.toFixed(0) + 'ms';
        },

        resetSettings_0: function() {
            ji2$config.smoothConfig = {
                a: true,  // interpolationEnabled
                b: 60,    // frameRateTarget
                c: 0.8,   // smoothingFactor
                d: true,  // lagCompensation
                e: true,  // predictionEnabled
                f: 100,   // maxPredictionTime
                g: false  // debugMode
            };

            // Update UI elements
            document.getElementById('smf-interpolation').checked = ji2$config.smoothConfig.a;
            document.getElementById('smf-prediction').checked = ji2$config.smoothConfig.e;
            document.getElementById('smf-lagcomp').checked = ji2$config.smoothConfig.d;
            document.getElementById('smf-debug').checked = ji2$config.smoothConfig.g;
            document.getElementById('smf-fps').value = ji2$config.smoothConfig.b;
            document.getElementById('smf-smoothing').value = ji2$config.smoothConfig.c;
            document.getElementById('smf-predtime').value = ji2$config.smoothConfig.f;

            // Update value displays
            document.getElementById('smf-fps-value').textContent = ji2$config.smoothConfig.b;
            document.getElementById('smf-smoothing-value').textContent = ji2$config.smoothConfig.c;
            document.getElementById('smf-predtime-value').textContent = ji2$config.smoothConfig.f + 'ms';

            console.log('[SMF] Settings reset to defaults');
        },

        exportSettings_0: function() {
            var settings_0 = JSON.stringify(ji2$config.smoothConfig, null, 2);
            navigator.clipboard.writeText(settings_0).then(function() {
                console.log('[SMF] Settings copied to clipboard');
                alert('Settings copied to clipboard!');
            });
        }
    };

    // Auto-initialization with DOM ready check
    function initWhenReady_0() {
        if (document.readyState === 'loading') {
            document.addEventListener('DOMContentLoaded', cggl$smoothFix.initialize_SmoothMovement_Enhanced);
        } else {
            cggl$smoothFix.initialize_SmoothMovement_Enhanced();
        }
    }

    // Start the enhanced smooth movement fix
    initWhenReady_0();

})();