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와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

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