FPS and Ping Drawer for Miniblox.io

Displays the current FPS and ping on miniblox.io

目前為 2024-07-04 提交的版本,檢視 最新版本

// ==UserScript==
// @name         FPS and Ping Drawer for Miniblox.io
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Displays the current FPS and ping on miniblox.io
// @author       Royal-Elite
// @match        *://miniblox.io/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Add a link to the Minecraft font stylesheet
    const fontLink = document.createElement('link');
    fontLink.href = 'https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap';
    fontLink.rel = 'stylesheet';
    document.head.appendChild(fontLink);

    // Create FPS counter element
    const fpsCounter = document.createElement('div');
    fpsCounter.style.position = 'fixed';
    fpsCounter.style.top = '10px'; // Adjust top position
    fpsCounter.style.left = '50%'; // Center horizontally
    fpsCounter.style.transform = 'translateX(-50%)'; // Adjust for centering
    fpsCounter.style.padding = '5px 10px';
    fpsCounter.style.backgroundColor = 'rgba(0, 0, 0, 0)'; // Transparent background
    fpsCounter.style.color = 'rgb(255, 0, 0)'; // Initial color: Red
    fpsCounter.style.fontSize = '14px';
    fpsCounter.style.zIndex = '9999';
    fpsCounter.style.fontFamily = '"Press Start 2P", cursive';
    document.body.appendChild(fpsCounter);

    // Create Ping display element
    const pingDisplay = document.createElement('div');
    pingDisplay.style.position = 'fixed';
    pingDisplay.style.top = '40px'; // Adjust top position for ping display
    pingDisplay.style.left = '50%'; // Center horizontally
    pingDisplay.style.transform = 'translateX(-50%)'; // Adjust for centering
    pingDisplay.style.padding = '5px 10px';
    pingDisplay.style.backgroundColor = 'rgba(0, 0, 0, 0)'; // Transparent background
    pingDisplay.style.color = 'rgb(0, 255, 0)'; // Initial color: Green
    pingDisplay.style.fontSize = '14px';
    pingDisplay.style.zIndex = '9999';
    pingDisplay.style.fontFamily = '"Press Start 2P", cursive';
    document.body.appendChild(pingDisplay);

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

    // Function to update FPS and change color based on criteria
    function updateFPS() {
        const currentTime = performance.now();
        frameCount++;

        if (currentTime - lastFrameTime >= 1000) {
            const fps = (frameCount / ((currentTime - lastFrameTime) / 1000)).toFixed(1);
            fpsCounter.innerText = `${fps} F/P/S`;
            lastFrameTime = currentTime;
            frameCount = 0;

            // Change color based on FPS criteria
            if (fps > 50) {
                fpsCounter.style.color = 'green';
            } else if (fps > 30) {
                fpsCounter.style.color = 'yellow';
            } else {
                fpsCounter.style.color = 'red';
            }
        }

        requestAnimationFrame(updateFPS);
    }

    updateFPS();

    // Function to update ping and change color based on criteria
    function updatePing() {
        const ping = Math.round(Math.random() * 150); // Simulated ping value (0-150 ms)
        pingDisplay.innerText = `${ping} M/S`;

        // Change color based on ping criteria
        if (ping < 50) {
            pingDisplay.style.color = 'green';
        } else if (ping < 100) {
            pingDisplay.style.color = 'yellow';
        } else {
            pingDisplay.style.color = 'red';
        }

        setTimeout(updatePing, 2000); // Update ping every 2 seconds (simulated)
    }

    updatePing();
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址