Diep.io Octo stacking script

I am Gay

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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;
            }
        }
    });
})();