Split Auto Clicker (Left = R, Right = T)

Auto clicks left mouse on R, right mouse on T (toggle keys)

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Split Auto Clicker (Left = R, Right = T)
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Auto clicks left mouse on R, right mouse on T (toggle keys)
// @author       ROcker_Cats_YT
// @match        *://bloxd.io/*
// @grant        none
// @license      MIT
// ==/UserScript==


(function () {
    'use strict';

    const CPS = 10; // clicks per second
    const interval = 1000 / CPS;

    let leftClicking = false;
    let rightClicking = false;
    let lastClickTime = 0;
    let targetCanvas = null;

    function getCanvas() {
        if (!targetCanvas || !document.contains(targetCanvas)) {
            targetCanvas = document.querySelector('canvas');
        }
        return targetCanvas;
    }

    function clickCanvas(button = 0) {
        const canvas = getCanvas();
        if (!canvas) return;

        const rect = canvas.getBoundingClientRect();
        const clientX = rect.left + rect.width / 2;
        const clientY = rect.top + rect.height / 2;

        ["mousedown", "mouseup", "click"].forEach(type => {
            const event = new MouseEvent(type, {
                bubbles: true,
                cancelable: true,
                view: window,
                clientX,
                clientY,
                button
            });
            canvas.dispatchEvent(event);
        });
    }

    function loop(timestamp) {
        if (timestamp - lastClickTime >= interval) {
            if (leftClicking) clickCanvas(0); // Left click
            if (rightClicking) clickCanvas(2); // Right click
            lastClickTime = timestamp;
        }
        requestAnimationFrame(loop);
    }

    document.addEventListener("keydown", e => {
        if (e.key.toLowerCase() === "r") {
            leftClicking = !leftClicking;
            console.log(`[AutoClicker] Left clicks: ${leftClicking ? "ON" : "OFF"}`);
        }
        if (e.key.toLowerCase() === "t") {
            rightClicking = !rightClicking;
            console.log(`[AutoClicker] Right clicks: ${rightClicking ? "ON" : "OFF"}`);
        }
    });

    requestAnimationFrame(loop);
})();