Diep.io Octo stacking script

I am Gay

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Diep.io Octo stacking script
// @namespace    http://tampermonkey.net/
// @license MIT
// @version      1.4
// @description  I am Gay
// @author       Arras Script God YT
// @match        *://diep.io/*
// @grant        none
// ==/UserScript==

(function () {
    let enabled = false;
    let realX = innerWidth / 2;
    let realY = innerHeight / 2;
    let fakeX = realX;
    let fakeY = realY;

    let tickCount = 0;
    const SWEEP_SPEED = 0.11; 
    
    const MAX_SWEEP_ANGLE = 360 * (Math.PI / 180); 

    let lastActiveTime = performance.now();
    let isPaused = false;
    let pauseStartTime = 0;

    function updateTargetCoordinates() {
        const now = performance.now();

        if (!isPaused && (now - lastActiveTime >= 500)) {
            isPaused = true;
            pauseStartTime = now;
        }

        if (isPaused) {
            if (now - pauseStartTime >= 1) {
                isPaused = false;
                lastActiveTime = now;
            } else {
                return; 
            }
        }

        const cx = innerWidth / 2;
        const cy = innerHeight / 2;
        const dx = realX - cx;
        const dy = realY - cy;
        
        const baseAngle = Math.atan2(dy, dx); 
        
        tickCount += SWEEP_SPEED;
        const currentAngleOffset = - (tickCount % MAX_SWEEP_ANGLE); 
        
        const targetAngle = baseAngle + currentAngleOffset;

        const dist = Math.max(Math.hypot(dx, dy), 300);
        
        fakeX = cx + dist * Math.cos(targetAngle);
        fakeY = cy + dist * Math.sin(targetAngle);
    }

    function autoLoop() {
        if (enabled) {
            updateTargetCoordinates();
            const canvas = document.querySelector("canvas");
            if (canvas) {
                const eventDict = { bubbles: true, clientX: fakeX, clientY: fakeY };
                canvas.dispatchEvent(new MouseEvent("mousemove", eventDict));
                canvas.dispatchEvent(new PointerEvent("pointermove", eventDict));
            }
        }
        requestAnimationFrame(autoLoop);
    }
    requestAnimationFrame(autoLoop);

    const oldAdd = EventTarget.prototype.addEventListener;
    EventTarget.prototype.addEventListener = function (type, listener, opts) {
        if (type === "mousemove" || type === "pointermove") {
            const wrapped = function (e) {
                if (e.isTrusted) {
                    realX = e.clientX;
                    realY = e.clientY;
                    
                    if (enabled) {
                        e.stopPropagation();
                        return; 
                    }
                }

                if (!enabled) return listener.call(this, e);

                const proxy = new Proxy(e, {
                    get(target, prop) {
                        if (['clientX', 'pageX', 'offsetX', 'screenX', 'x'].includes(prop)) return fakeX;
                        if (['clientY', 'pageY', 'offsetY', 'screenY', 'y'].includes(prop)) return fakeY;
                        if (['movementX', 'movementY'].includes(prop)) return 0;
                        
                        const value = target[prop];
                        return typeof value === 'function' ? value.bind(target) : value;
                    }
                });

                return listener.call(this, proxy);
            };
            return oldAdd.call(this, type, wrapped, opts);
        }
        return oldAdd.call(this, type, listener, opts);
    };

    addEventListener("keydown", e => {
        if (e.key.toLowerCase() === "p") {
            enabled = !enabled;
            if (enabled) {
                fakeX = realX;
                fakeY = realY;
                tickCount = 0; 
                lastActiveTime = performance.now();
                isPaused = false;
            }
        }
    });
})();