Auto Click Target on Mouse Accuracy

Tự động bấm vào tất cả div chứa target trên mouseaccuracy.com

Versione datata 12/12/2024. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Auto Click Target on Mouse Accuracy
// @namespace    http://tampermonkey.net/
// @version      1.5
// @description  Tự động bấm vào tất cả div chứa target trên mouseaccuracy.com
// @author       HưngVN
// @license      DONOTCOPY
// @match        https://mouseaccuracy.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let isClicking = false;  // Biến kiểm tra xem có đang click hay không

    // Hàm để mô phỏng sự kiện click
    function simulateMouseEvent(element, eventType) {
        const mouseEvent = new MouseEvent(eventType, {
            bubbles: true,
            cancelable: true,
            view: window
        });
        element.dispatchEvent(mouseEvent);
    }

    // Hàm kiểm tra và click vào các phần tử target
    function autoClickTarget() {
        const targets = document.querySelectorAll('.target');

        if (targets.length > 0 && !isClicking) {
            isClicking = true;  // Đánh dấu là đang click

            // Lặp qua tất cả các phần tử .target và mô phỏng click
            targets.forEach((target) => {
                simulateMouseEvent(target, 'mousedown');
                simulateMouseEvent(target, 'mouseup');
                simulateMouseEvent(target, 'click');
                console.log('Đã click vào target!');
            });

            // Đặt lại trạng thái sau khi click
            setTimeout(() => {
                isClicking = false;
            }, 100);  // Giới hạn thời gian click mỗi lần (500ms)
        } else {
            console.log('Không tìm thấy target hoặc đang bấm quá nhanh.');
        }
    }

    // Sử dụng MutationObserver để theo dõi thay đổi trên trang
    const observer = new MutationObserver((mutations) => {
        mutations.forEach(() => {
            autoClickTarget();
        });
    });

    // Cấu hình cho MutationObserver để theo dõi các thay đổi con (các phần tử con của body)
    observer.observe(document.body, {
        childList: true,    // Theo dõi thay đổi của các phần tử con
        subtree: true       // Theo dõi thay đổi trong toàn bộ cây DOM
    });

    // Đảm bảo click ngay từ đầu nếu phần tử đã có mặt
    autoClickTarget();
})();