Motion Blur Thingy

Ehh kinda works but not REAL Motion Blur...

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

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