CS Timer Realistic Generator (Always-On Input)

Generate realistic solve times manually in CS Timer & ensure input is always active

2025-04-15 يوللانغان نەشرى. ئەڭ يېڭى نەشرىنى كۆرۈش.

// ==UserScript==
// @name         CS Timer Realistic Generator (Always-On Input)
// @namespace    http://tampermonkey.net/
// @version      1.9
// @description  Generate realistic solve times manually in CS Timer & ensure input is always active
// @author       YourName
// @match        https://cstimer.net/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

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

        let timeInput = document.getElementById("inputTimer");
        if (timeInput) {
            timeInput.style.display = "inline-block"; // Ensure visibility
            timeInput.value = randomTime;
            timeInput.dispatchEvent(new Event('input'));
            timeInput.focus(); // Keep focus on the input field
        }

        let historyTable = document.querySelector("#timeList tbody"); 
        if (historyTable) {
            let newRow = document.createElement("tr");
            let solveCount = historyTable.children.length;
            newRow.setAttribute("data", solveCount);

            let indexCell = document.createElement("td");
            indexCell.classList.add("times", "custom-cursor-on-hover");
            indexCell.innerText = solveCount + 1;

            let timeCell = document.createElement("td");
            timeCell.classList.add("times", "custom-cursor-on-hover");
            timeCell.innerText = randomTime;

            let emptyCell1 = document.createElement("td");
            emptyCell1.innerText = "-";

            let emptyCell2 = document.createElement("td");
            emptyCell2.innerText = "-";

            newRow.appendChild(indexCell);
            newRow.appendChild(timeCell);
            newRow.appendChild(emptyCell1);
            newRow.appendChild(emptyCell2);
            historyTable.appendChild(newRow);
        }
    }

    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();
})();