Motion Blur Thingy

Ehh kinda works but not REAL Motion Blur...

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

You will need to install an extension such as Tampermonkey 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         Motion Blur Thingy
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Ehh kinda works but not REAL Motion Blur...
// @author       Ankit
// @match        https://bloxd.io/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
    let lastHeading = null;
    let lastPitch = null;
    let currentBlur = 0;

    const MAX_BLUR = 6;
    const MULTIPLIER = 12;
    const SMOOTHING = 0.15;
    const THRESHOLD = 0.0005;

    function findNoa() {
        const isNoa = o =>
        o && typeof o === "object" &&
              o.entities?.getState &&
              o.camera?.getDirection &&
              o.world?.getBlock;

        const isEntityMgr = o =>
        o && typeof o === "object" &&
              o.entities?.getState;

        function scan(obj, check, seen = new Set()) {
            if (!obj || typeof obj !== "object" || seen.has(obj)) return null;
            seen.add(obj);

            try {
                if (check(obj)) return obj;
                for (const v of Object.values(obj)) {
                    const hit = scan(v, check, seen);
                    if (hit) return hit;
                }
            } catch {}
            return null;
        }

        function walk(fiber) {
            let n = fiber, i = 0;
            while (n && i++ < 40) {
                if (n.memoizedProps) {
                    const r =
                          scan(n.memoizedProps, isNoa) ||
                          scan(n.memoizedProps, isEntityMgr);
                    if (r) return r;
                }
                if (n.memoizedState) {
                    const r =
                          scan(n.memoizedState, isNoa) ||
                          scan(n.memoizedState, isEntityMgr);
                    if (r) return r;
                }
                n = n.return;
            }
            return null;
        }

        for (const el of document.querySelectorAll("*")) {
            const k = Object.keys(el).find(x => x.startsWith("__reactFiber$"));
            if (!k) continue;
            const r = walk(el[k]);
            if (r) return r;
        }

        return null;
    }

    function logNoa() {
        const InGame = document.querySelector(".HotBarContainer");

        if (InGame && !window.__noa) {
            window.__noa = findNoa();
        }
    }

    function normalizeAngle(delta) {
        if (delta > Math.PI) delta -= Math.PI * 2;
        if (delta < -Math.PI) delta += Math.PI * 2;
        return delta;
    }

    function motionBlurLoop() {
        const container = document.querySelector("#noa-container");
        if (!container || !window.__noa) {
            requestAnimationFrame(motionBlurLoop);
            return;
        }

        const cam = window.__noa.camera;

        const heading = cam.heading;
        const pitch = cam.pitch;

        if (lastHeading !== null) {
            let deltaYaw = normalizeAngle(heading - lastHeading);
            let deltaPitch = pitch - lastPitch;

            let velocity = Math.sqrt(deltaYaw * deltaYaw + deltaPitch * deltaPitch);

            let targetBlur = velocity > THRESHOLD
            ? Math.min(velocity * MULTIPLIER, MAX_BLUR)
            : 0;

            // Smooth interpolation
            currentBlur += (targetBlur - currentBlur) * SMOOTHING;

            container.style.filter =
                currentBlur > 0.01
                ? `blur(${currentBlur}px) brightness(1.03)`
            : "none";
        }

        lastHeading = heading;
        lastPitch = pitch;

        requestAnimationFrame(motionBlurLoop);
    }

    requestAnimationFrame(motionBlurLoop);
    requestAnimationFrame(logNoa);
})();