Diep.io Octo stacking script

I am Gay

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

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