Live Ping Display in zombsroyale.io

Displays Real Time Ping in zombsroyale.io

  1. // ==UserScript==
  2. // @name Live Ping Display in zombsroyale.io
  3. // @namespace zombsroyale.io
  4. // @version 1.0
  5. // @description Displays Real Time Ping in zombsroyale.io
  6. // @match zombsroyale.io
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. (function() {
  11. 'use strict';
  12.  
  13. var pingDisplay = document.createElement('div');
  14. pingDisplay.style.position = 'fixed';
  15. pingDisplay.style.top = '10px';
  16. pingDisplay.style.left = '10px';
  17. pingDisplay.style.zIndex = '9999';
  18. pingDisplay.style.backgroundColor = 'white';
  19. pingDisplay.style.padding = '10px';
  20. document.body.appendChild(pingDisplay);
  21.  
  22. function measurePing() {
  23. var startTime = new Date().getTime();
  24. var xhr = new XMLHttpRequest();
  25. xhr.open('HEAD', window.location.href + '?rand=' + Math.random(), true);
  26. xhr.onreadystatechange = function() {
  27. if (xhr.readyState === 4) {
  28. var endTime = new Date().getTime();
  29. var ping = endTime - startTime;
  30. pingDisplay.textContent = 'Ping: ' + ping + ' ms';
  31. }
  32. };
  33. xhr.send(null);
  34. }
  35.  
  36. setInterval(measurePing, 125);
  37. })();