FPS显示

FPS显示是一个用户脚本,旨在为移动端设备提供实时的帧率 (FPS) 显示。该脚本在页面的固定位置创建一个半透明的显示框,实时更新并展示当前页面的帧率信息。

目前為 2024-06-21 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         FPS显示
// @namespace    http://tampermonkey.net/
// @version      0.1.2
// @description  FPS显示是一个用户脚本,旨在为移动端设备提供实时的帧率 (FPS) 显示。该脚本在页面的固定位置创建一个半透明的显示框,实时更新并展示当前页面的帧率信息。
// @license      MIT
// @author       zzzwq
// @match        http://*/*
// @match        https://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var bzyfps;
    if (!document.getElementById("fps")) {
        bzyfps = document.createElement("span");
        bzyfps.id = "fps";
        bzyfps.innerHTML = "fps:0";
        bzyfps.style.cssText =
            "text-align:center !important;font-size:15px;width:60px;height:28px;line-height:28px;text-align:center;float:right;position:fixed;right:10px;top:10px;color:#9370DB;background:transparent;cursor:pointer;z-index:999999999;box-shadow:0px 0px 10px #888;border-radius:10%;user-select:none";
        // 修改: 确保点击穿透
        bzyfps.style.pointerEvents = 'none';
        document.body.appendChild(bzyfps);
    }

    var showFPS = function() {
        var t, n, e, o, i, p = window.requestAnimationFrame || window.mozRequestAnimationFrame || function(t) {
            window.setTimeout(t, 1e3 / 60);
        };

        return (
            (t = 0),
            (n = Date.now()),
            (o = function() {
                (e = Date.now() - n), t += 1, e >= 1e3 && ((n += e), i(t), (t = 0)), p(o);
            }),
            (i = function(t) {
                bzyfps.innerHTML = "fps:" + t;
            }),
            {
                setParentElementId: function(t) {
                    t;
                },
                go: function() {
                    o();
                }
            }
        );
    }();

    showFPS.go();

    // 修改: 移除显示/隐藏逻辑,确保FPS显示框常驻显示
    bzyfps.style.display = 'block';

})();