Random Clicker

Auto Clicker for Browsers!!

ของเมื่อวันที่ 04-09-2023 ดู เวอร์ชันล่าสุด

// ==UserScript==
// @name         Random Clicker
// @namespace    
// @version      1.11
// @description  Auto Clicker for Browsers!!
// @author       
// @match        *://*/*
// @grant        none
// @icon         
// @compatible               chrome
// @compatible               firefox
// @compatible               opera
// @compatible               safari
// ==/UserScript==

let x, y, minCPS = 1, maxCPS = 5, autoClick;
let infoElement = document.createElement("div");
infoElement.style.position = "fixed";
infoElement.style.top = "10px";
infoElement.style.left = "10px";
document.body.appendChild(infoElement);

function updateInfo(message) {
    infoElement.textContent = message;
}

function startAutoClick(x, y) {
    // Generate a new random CPS
    let randomCPS = Math.floor(Math.random() * (maxCPS - minCPS + 1)) + minCPS;

    autoClick = setInterval(function () {
        if (x !== undefined && y !== undefined) {
            click(x, y, randomCPS); // Pass the coordinates and random CPS to the click function
        }
    }, 1000 / randomCPS); // Convert CPS to milliseconds
}

function stopAutoClick() {
    clearInterval(autoClick); // Clear the autoClick interval
    x = undefined;
    y = undefined;
}

document.addEventListener('keydown', function (evt) {
    if (evt.shiftKey && evt.key === 'J') {
        if (autoClick) {
            stopAutoClick(); // Stop the previous autoclick interval
        }

        updateInfo("You may now click on any point in this tab to set the autoclicker to it. Have fun !!");

        document.addEventListener('click', function (event) {
            x = event.clientX;
            y = event.clientY;
            updateInfo(`Mouse click at X: ${x}, Y: ${y}`);
            startAutoClick(x, y); // Start autoclicking at the new coordinates
        });
    }
});

function click(x, y, randomCPS) {
    // You can still display information here if needed
    let ev = new MouseEvent('click', {
        'view': window,
        'bubbles': true,
        'cancelable': true,
        'screenX': x,
        'screenY': y
    });

    let el = document.elementFromPoint(x, y);
    el.dispatchEvent(ev);
}