Motion Blur Thingy

Ehh kinda works but not REAL Motion Blur...

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

You will need to install an extension such as Tampermonkey 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         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);
})();