Auto Clicker Toggle randomized

Toggle autoclicker with E, randomized 95-100 CPS at cursor (every millisecond)

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Auto Clicker Toggle randomized
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  Toggle autoclicker with E, randomized 95-100 CPS at cursor (every millisecond)
// @author       You
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    let autoClicking = false;
    let clickInterval;
    let mouseX = 0, mouseY = 0;

    // Track mouse position
    document.addEventListener("mousemove", e => {
        mouseX = e.clientX;
        mouseY = e.clientY;
    });

    function startClicking() {
        if (clickInterval) return;

        function clickLoop() {
            if (!autoClicking) return;

            // Randomize CPS (95–100) *every millisecond*
            let cps = Math.floor(Math.random() * 6) + 95; // 95–100
            let delay = 1000 / cps; // convert to ms per click

            // Find element under cursor
            const target = document.elementFromPoint(mouseX, mouseY);
            if (target) {
                ["mousedown", "mouseup", "click"].forEach(type => {
                    target.dispatchEvent(new MouseEvent(type, {
                        bubbles: true,
                        cancelable: true,
                        view: window,
                        clientX: mouseX,
                        clientY: mouseY,
                        buttons: 1
                    }));
                });
            }

            // Schedule next click with freshly randomized delay
            clickInterval = setTimeout(clickLoop, delay);
        }
        clickLoop();
    }

    function stopClicking() {
        clearTimeout(clickInterval);
        clickInterval = null;
    }

    // Toggle with "E"
    document.addEventListener('keydown', function (e) {
        if (e.key.toLowerCase() === 'e') {
            autoClicking = !autoClicking;
            if (autoClicking) {
                console.log("AutoClicker ON");
                startClicking();
            } else {
                console.log("AutoClicker OFF");
                stopClicking();
            }
        }
    });
})();