Contador de CPS en Sploop.io

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Contador de CPS en Sploop.io
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Muestra el número de clics por segundo (CPS) en Sploop.io
// @author       Tú
// @license MIT
// @match        *://sploop.io/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const Cps = {
        count: 0,
        element: null,

        // Disminuye el contador
        reduce: function() {
            this.count -= 1;
            this.updateText();
        },

        // Aumenta el contador
        increase: function() {
            this.count += 1;
            this.updateText();
        },

        // Actualiza el texto del contador
        updateText: function() {
            this.element.textContent = `Cps: ${this.count < 0 ? 0 : this.count}`;
        },

        // Crea el elemento para mostrar el CPS
        createElement: function() {
            this.element = document.createElement('div');
            this.element.style.position = 'fixed';
            this.element.style.top = '299px';
            this.element.style.left = '5px'; // Cambiado a la izquierda
            this.element.style.color = 'white';
            this.element.style.fontSize = '30px';
            this.element.style.textAlign = 'left'; // Alineación a la izquierda
            this.element.style.pointerEvents = 'none';
            document.body.appendChild(this.element);
            this.updateText();
        },

        // Función para retrasar la ejecución
        sleep: function(ms) {
            return new Promise(resolve => setTimeout(resolve, ms));
        },

        // Función principal para actualizar el CPS
        update: async function() {
            this.increase();
            await this.sleep(1000);
            this.reduce();
        }
    };

    // Crea el elemento CPS
    Cps.createElement();

    // Escucha los clics del ratón
    document.addEventListener('mousedown', () => {
        Cps.update();
    });

    // Controla la barra espaciadora
    let spaceActive = false;
    document.addEventListener('keydown', (event) => {
        if (event.code === 'Space' && !spaceActive) {
            Cps.update();
            spaceActive = true;
        }
    });

    document.addEventListener('keyup', (event) => {
        if (event.code === 'Space') {
            spaceActive = false;
        }
    });
})();