JavaScript Auto Clicker

javascript 3 views 2 hours, 19 minutes ago Public
Raw Download
javascript 1238 characters
// Auto Clicker - Click any element repeatedly
// Usage: Run in browser console, then click on the element you want to auto-click

let autoClickInterval = null;
let targetElement = null;

function startAutoClicker(intervalMs = 100) {
    console.log('Click on the element you want to auto-click...');
    
    document.addEventListener('click', function captureTarget(e) {
        e.preventDefault();
        e.stopPropagation();
        targetElement = e.target;
        
        console.log('Target captured:', targetElement);
        console.log('Starting auto-clicker at', intervalMs, 'ms intervals');
        
        autoClickInterval = setInterval(() => {
            targetElement.click();
            console.log('Clicked!');
        }, intervalMs);
        
        document.removeEventListener('click', captureTarget, true);
    }, true);
}

function stopAutoClicker() {
    if (autoClickInterval) {
        clearInterval(autoClickInterval);
        autoClickInterval = null;
        console.log('Auto-clicker stopped');
    }
}

// Start the auto-clicker (100ms = 10 clicks per second)
startAutoClicker(100);

// To stop: stopAutoClicker();
// To change speed: stopAutoClicker(); startAutoClicker(50); // 50ms = 20 clicks/sec