Auto Click Target on Mouse Accuracy

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

Verze ze dne 12. 12. 2024. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

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