Miniblox FPS Display

Affiche le nombre de FPS en haut à gauche de l'écran

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Miniblox FPS Display
// @namespace    https://github.com/AdrienPlaza
// @version      1.0
// @description  Affiche le nombre de FPS en haut à gauche de l'écran
// @author       PrimeFR
// @match        https://miniblox.io/*
// @icon         https://miniblox.io/favicon.png
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const fpsDisplay = document.createElement('div');
    fpsDisplay.style.position = 'fixed';
    fpsDisplay.style.top = '10px';
    fpsDisplay.style.right = '10px';
    fpsDisplay.style.backgroundColor = 'purple';
    fpsDisplay.style.color = 'white';
    fpsDisplay.style.border = '2px solid black';
    fpsDisplay.style.padding = '5px';
    fpsDisplay.style.zIndex = '1000';
    fpsDisplay.style.fontFamily = 'Arial, sans-serif';
    fpsDisplay.style.fontSize = '14px';
    document.body.appendChild(fpsDisplay);

    let lastTimestamp = performance.now();
    let frames = 0;

    function updateFPS() {
        const now = performance.now();
        frames++;

        if (now - lastTimestamp >= 1000) {
            const fps = frames;
            fpsDisplay.textContent = `FPS: ${fps}`;
            frames = 0;
            lastTimestamp = now;
        }

        requestAnimationFrame(updateFPS);
    }

    updateFPS();
})();