Tự động bấm vào tất cả div chứa target trên mouseaccuracy.com
Verze ze dne
// ==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();
})();