Live FPS Display

Displays Real Time FPS on zombsroyale.io

  1. // ==UserScript==
  2. // @name Live FPS Display
  3. // @namespace zombsroyale.io
  4. // @version 4.0
  5. // @description Displays Real Time FPS on zombsroyale.io
  6. // @match zombsroyale.io
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. (function() {
  11. 'use strict';
  12.  
  13. var fpsDisplay = document.createElement('div');
  14. fpsDisplay.style.position = 'fixed';
  15. fpsDisplay.style.top = '10px';
  16. fpsDisplay.style.right = '10px';
  17. fpsDisplay.style.padding = '5px';
  18. fpsDisplay.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
  19. fpsDisplay.style.color = '#fff';
  20. fpsDisplay.style.zIndex = '9999';
  21.  
  22. document.body.appendChild(fpsDisplay);
  23.  
  24. var frameCount = 0;
  25. var startTime = performance.now();
  26.  
  27. function updateFPS() {
  28. var endTime = performance.now();
  29. var elapsed = endTime - startTime;
  30. var fps = Math.round(frameCount / (elapsed / 1000));
  31.  
  32. fpsDisplay.textContent = 'FPS: ' + fps;
  33. frameCount = 0;
  34. startTime = endTime;
  35.  
  36. setTimeout(updateFPS, 100);
  37. }
  38.  
  39. // Function to count frames
  40. function countFrames() {
  41. frameCount++;
  42. requestAnimationFrame(countFrames);
  43. }
  44.  
  45. countFrames();
  46. updateFPS();
  47. })();