CS Timer Realistic Auto Generator

Automatically generates realistic times every 10ms with simulated typing, prioritizing 3.16-5.01 seconds

目前为 2025-04-15 提交的版本。查看 最新版本

// ==UserScript==
// @name         CS Timer Realistic Auto Generator
// @namespace    http://tampermonkey.net/
// @version      2.3
// @description  Automatically generates realistic times every 10ms with simulated typing, prioritizing 3.16-5.01 seconds
// @author       YourName
// @match        https://cstimer.net/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function simulateTyping(element, text, delay) {
        let index = 0;
        element.value = "";

        function typeChar() {
            if (index < text.length) {
                element.value += text[index];
                index++;
                setTimeout(typeChar, delay);
            } else {
                element.dispatchEvent(new Event('input'));
            }
        }

        typeChar();
    }

    function generateTime() {
        let randomChance = Math.random();
        let randomTime;

        if (randomChance < 0.8) { // 80% chance of generating a time between 3.16 and 5.01
            randomTime = (Math.random() * (5.01 - 3.16) + 3.16).toFixed(2);
        } else { // 20% chance of generating a time between 1.84 and 6.06 for variety
            randomTime = (Math.random() * (6.06 - 1.84) + 1.84).toFixed(2);
        }

        document.getElementById("timeDisplay").innerText = `Generated Time: ${randomTime} seconds`;

        let timeInput = document.getElementById("inputTimer");
        if (timeInput) {
            timeInput.style.display = "inline-block"; 
            timeInput.focus();
            simulateTyping(timeInput, randomTime, 10); // Simulates 10ms typing per character
        }

        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 startAutoGenerate() {
        setInterval(generateTime, 10); // Generates a new time every 10ms
    }

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

        document.body.appendChild(container);
    }

    createUI();
    startAutoGenerate(); // Start generating times immediately
})();