CTRL+Click Auto-Clicker (100ms)

Starts auto-clicking at 100ms intervals on the element clicked with CTRL (or ⌘) + Left Click. Stops with a normal click or ESC.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         CTRL+Click Auto-Clicker (100ms)
// @namespace    https://tr-wp.com/
// @version      1.0
// @description  Starts auto-clicking at 100ms intervals on the element clicked with CTRL (or ⌘) + Left Click. Stops with a normal click or ESC.
// @author       Yoka - tr-wp.com
// @match        *://*/*
// @grant        none
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';

    let intervalId = null;
    let targetElement = null;
    let originalOutline = null;

    function simulateClick(el) {
        if (!el) return;
        
        const rect = el.getBoundingClientRect();
        const clientX = rect.left + rect.width / 2;
        const clientY = rect.top + rect.height / 2;

        const createMouseEvent = (type) => new MouseEvent(type, {
            bubbles: true,
            cancelable: true,
            view: window,
            clientX,
            clientY,
            button: 0
        });

        el.dispatchEvent(createMouseEvent('mousedown'));
        el.dispatchEvent(createMouseEvent('mouseup'));
        el.dispatchEvent(createMouseEvent('click'));
    }

    function startAutoClicking(el) {
        stopAutoClicking();

        targetElement = el;
        originalOutline = el.style.outline || '';
        el.style.outline = '2px solid red';

        intervalId = setInterval(() => {
            if (!document.contains(targetElement)) {
                stopAutoClicking();
                return;
            }
            simulateClick(targetElement);
        }, 100);
    }

    function stopAutoClicking() {
        if (intervalId !== null) {
            clearInterval(intervalId);
            intervalId = null;
            if (targetElement) {
                try { 
                    targetElement.style.outline = originalOutline; 
                } catch(e) {}
            }
            targetElement = null;
            originalOutline = null;
        }
    }

    window.addEventListener('mousedown', function(e) {
        if (!e.isTrusted) return;
        if ((e.button === 0) && (e.ctrlKey || e.metaKey)) {
            startAutoClicking(e.target);
        }
    }, true);

    window.addEventListener('click', function(e) {
        if (!e.isTrusted) return;
        if (intervalId !== null) {
            if (!(e.ctrlKey || e.metaKey)) {
                stopAutoClicking();
            }
        }
    }, true);

    window.addEventListener('keydown', function(e) {
        if (e.key === 'Escape' || e.key === 'Esc') {
            stopAutoClicking();
        }
    });

    window.addEventListener('beforeunload', stopAutoClicking);
})();