Random Clicker

Auto Clicker for Browsers!!

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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 isAutoClicking = false;

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 && isAutoClicking) {
            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
    isAutoClicking = false;
    x = undefined;
    y = undefined;
}

document.addEventListener('keydown', function (evt) {
    if (evt.shiftKey && evt.key === 'J') {
        if (isAutoClicking) {
            stopAutoClick(); // Stop the autoclick when Shift+J is pressed
        } else {
            updateInfo("You may now click on any point in this tab to set the autoclicker to it. Have fun !!");
        }
    }
});

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

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

// Helper function to update the information on the page
function updateInfo(message) {
    let infoElement = document.getElementById("autoclick-info");
    if (!infoElement) {
        infoElement = document.createElement("div");
        infoElement.id = "autoclick-info";
        infoElement.style.position = "fixed";
        infoElement.style.top = "10px";
        infoElement.style.left = "10px";
        document.body.appendChild(infoElement);
    }
    infoElement.textContent = message;
}