Motion Blur Thingy

Ehh kinda works but not REAL Motion Blur...

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==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);
})();