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

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

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