Diep.io Octo stacking script

I am Gay

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

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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;
            }
        }
    });
})();