Contador de CPS en Sploop.io

Muestra el número de clics por segundo (CPS) en Sploop.io

  1. // ==UserScript==
  2. // @name Contador de CPS en Sploop.io
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description Muestra el número de clics por segundo (CPS) en Sploop.io
  6. // @author Tú
  7. // @license MIT
  8. // @match *://sploop.io/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. const Cps = {
  16. count: 0,
  17. element: null,
  18.  
  19. // Disminuye el contador
  20. reduce: function() {
  21. this.count -= 1;
  22. this.updateText();
  23. },
  24.  
  25. // Aumenta el contador
  26. increase: function() {
  27. this.count += 1;
  28. this.updateText();
  29. },
  30.  
  31. // Actualiza el texto del contador
  32. updateText: function() {
  33. this.element.textContent = `Cps: ${this.count < 0 ? 0 : this.count}`;
  34. },
  35.  
  36. // Crea el elemento para mostrar el CPS
  37. createElement: function() {
  38. this.element = document.createElement('div');
  39. this.element.style.position = 'fixed';
  40. this.element.style.top = '299px';
  41. this.element.style.left = '5px'; // Cambiado a la izquierda
  42. this.element.style.color = 'white';
  43. this.element.style.fontSize = '30px';
  44. this.element.style.textAlign = 'left'; // Alineación a la izquierda
  45. this.element.style.pointerEvents = 'none';
  46. document.body.appendChild(this.element);
  47. this.updateText();
  48. },
  49.  
  50. // Función para retrasar la ejecución
  51. sleep: function(ms) {
  52. return new Promise(resolve => setTimeout(resolve, ms));
  53. },
  54.  
  55. // Función principal para actualizar el CPS
  56. update: async function() {
  57. this.increase();
  58. await this.sleep(1000);
  59. this.reduce();
  60. }
  61. };
  62.  
  63. // Crea el elemento CPS
  64. Cps.createElement();
  65.  
  66. // Escucha los clics del ratón
  67. document.addEventListener('mousedown', () => {
  68. Cps.update();
  69. });
  70.  
  71. // Controla la barra espaciadora
  72. let spaceActive = false;
  73. document.addEventListener('keydown', (event) => {
  74. if (event.code === 'Space' && !spaceActive) {
  75. Cps.update();
  76. spaceActive = true;
  77. }
  78. });
  79.  
  80. document.addEventListener('keyup', (event) => {
  81. if (event.code === 'Space') {
  82. spaceActive = false;
  83. }
  84. });
  85. })();