Show FPS

Hiển thị FPS trên tất cả các trang web

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Show FPS
// @namespace    https://discord.gg/gmQZpuneKh
// @version      1.0
// @description  Hiển thị FPS trên tất cả các trang web
// @match        *://*/*
// @author       ! 3sut2z !
// @icon         https://media.discordapp.net/attachments/1223491413786890240/1240466088802783323/3s.png?ex=6647fb12&is=6646a992&hm=89cdb265807c91a6a344ff4f2620a75108f83cca48adfb84e0971ba264618e01&=&format=webp&quality=lossless&width=427&height=427
// @grant        none
// @license MIT2
// ==/UserScript==

(function() {
    'use strict';

    // Tạo một div để hiển thị FPS
    const fpsDiv = document.createElement('div');
    fpsDiv.style.position = 'fixed';
    fpsDiv.style.top = '10px';
    fpsDiv.style.left = '10px';
    fpsDiv.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
    fpsDiv.style.color = 'white';
    fpsDiv.style.padding = '5px';
    fpsDiv.style.zIndex = '10000';
    document.body.appendChild(fpsDiv);

    let lastFrameTime = performance.now();
    let frameCount = 0;
    let fps = 0;

    function updateFPS() {
        const now = performance.now();
        frameCount++;
        const delta = now - lastFrameTime;

        if (delta >= 1000) {
            fps = (frameCount / delta) * 1000;
            fpsDiv.textContent = `FPS: ${fps.toFixed(1)}`;
            frameCount = 0;
            lastFrameTime = now;
        }

        requestAnimationFrame(updateFPS);
    }

    // Bắt đầu đo lường FPS
    requestAnimationFrame(updateFPS);
})();