Greasy Fork

Survev.io Counters

Give survev.io better experience

目前为 2024-10-28 提交的版本。查看 最新版本

// ==UserScript==
// @name         Survev.io Counters
// @namespace    http://tampermonkey.net/
// @license      MIT
// @version      2024-10-28
// @description  Give survev.io better experience
// @author       chess5321, Asultra, Samer Kizi, #NARS & other og authors (Discord#)
// @match        https://survev.io/
// @icon         https://cdn.discordapp.com/icons/947128006030282792/c80363d8d6dea22ef392c4d325e0c9f4.png?size=64
// @grant        none
// ==/UserScript==


(function() {
    'use strict';

let MAX = 144; //frame rate you desire
requestAnimationFrame = (a) => setTimeout(a, 1e3/MAX)
})();

(function() {
    let fps = 0;
    let ping = 0;
    let lastLoop = performance.now();
    let frameCount = 0;

    // Create FPS display
    const fpsDisplay = document.createElement('div');
    fpsDisplay.style.position = 'absolute';
    fpsDisplay.style.top = '50%'; // Middle of the screen vertically
    fpsDisplay.style.left = '10px'; // Left side of the screen
    fpsDisplay.style.transform = 'translateY(-50%)'; // Centers it vertically based on the top position
    fpsDisplay.style.color = 'white';
    fpsDisplay.style.fontSize = '14px'; // Smaller font size
    fpsDisplay.style.fontFamily = '"Arial", sans-serif'; // Regular Arial font without bold
    fpsDisplay.style.textShadow = '1px 1px 2px black'; // Slight shadow for visibility
    fpsDisplay.style.backgroundColor = 'rgba(0, 0, 0, 0.3)';
    fpsDisplay.style.padding = '3px 5px'; // Padding around the text
    fpsDisplay.style.borderRadius = '3px'; // Slightly rounded corners for styling
    fpsDisplay.style.zIndex = '10000'; // Ensure the FPS display is on top
    fpsDisplay.innerHTML = `FPS: 0`;
    document.body.appendChild(fpsDisplay);

    function updateCounters() {
        const currentLoop = performance.now();
        const delta = currentLoop - lastLoop;

        // Update FPS
        frameCount++;
        if (delta >= 1000) {
            fps = frameCount;
            frameCount = 0;
            lastLoop = currentLoop;
            fpsDisplay.innerHTML = `FPS: ${fps}`;
        }

        // Request the next frame
        requestAnimationFrame(updateCounters);
    }

    // Start the counters
    updateCounters();

})();

(function() {
    'use strict';
    var lastHP = 0
    var health = document.createElement("span");
    health.style = "display:block;position:fixed;z-index: 2;margin:6px 0 0 0;right: 15px;mix-blend-mode: difference;font-weight: bold;font-size:large;";
    document.querySelector("#ui-health-container").appendChild(health);

    var adr = document.createElement("span");
    adr.style = "display:block;position:fixed;z-index: 2;margin:6px 0 0 0;left: 15px;mix-blend-mode: difference;font-weight: bold;font-size:large;";
    document.querySelector("#ui-health-container").appendChild(adr);

    setInterval(function(){
        var hp = document.getElementById("ui-health-actual").style.width.slice(0,-1)
        if(lastHP !== hp){
            lastHP = hp
            health.innerHTML = Math.round(hp)
        }
        var boost0 = document.getElementById("ui-boost-counter-0").querySelector(".ui-bar-inner").style.width.slice(0,-1),
            boost1 = document.getElementById("ui-boost-counter-1").querySelector(".ui-bar-inner").style.width.slice(0,-1),
            boost2 = document.getElementById("ui-boost-counter-2").querySelector(".ui-bar-inner").style.width.slice(0,-1),
            boost3 = document.getElementById("ui-boost-counter-3").querySelector(".ui-bar-inner").style.width.slice(0,-1),
            adr0 = boost0*25/100 + boost1*25/100 + boost2*37.5/100 + boost3*12.5/100
        adr.innerHTML = Math.round(adr0)
    })
})();