CS Timer Auto-Generator with UI

Generate random solve times with a user interface in CS Timer

Od 15.04.2025.. Pogledajte najnovija verzija.

// ==UserScript==
// @name         CS Timer Auto-Generator with UI
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  Generate random solve times with a user interface in CS Timer
// @author       YourName
// @match        https://cstimer.net/*
// @grant        none
// @license      MIT-
// ==/UserScript==

(function() {
    'use strict';

    function generateTime() {
        let randomTime = (Math.random() * (30 - 5) + 5).toFixed(2);
        document.getElementById("timeDisplay").innerText = `Generated Time: ${randomTime} seconds`;

        // Update the CS Timer input field with the generated time
        let timeInput = document.getElementById("inputTimer");
        if (timeInput) {
            timeInput.value = randomTime;
            timeInput.dispatchEvent(new Event('input')); // Trigger input event in case CS Timer reacts to it
        }
    }

    function createUI() {
        let container = document.createElement("div");
        container.style.position = "fixed";
        container.style.bottom = "20px";
        container.style.right = "20px";
        container.style.padding = "15px";
        container.style.background = "#f9f9f9";
        container.style.border = "2px solid #ccc";
        container.style.borderRadius = "5px";
        container.style.zIndex = "1000";
        container.style.boxShadow = "2px 2px 10px rgba(0,0,0,0.2)";
        container.style.textAlign = "center";

        let title = document.createElement("h3");
        title.innerText = "CS Timer Generator";
        container.appendChild(title);

        let timeDisplay = document.createElement("p");
        timeDisplay.id = "timeDisplay";
        timeDisplay.innerText = "Time will appear here...";
        container.appendChild(timeDisplay);

        let button = document.createElement("button");
        button.innerText = "Generate Time";
        button.style.padding = "10px";
        button.style.fontSize = "16px";
        button.onclick = generateTime;
        container.appendChild(button);

        document.body.appendChild(container);
    }

    createUI();
})();