function simulateClick(x, y) {
var event = new MouseEvent('click', {
bubbles: true,
cancelable: true,
view: window,
clientX: x,
clientY: y
});
var clickedElement = document.elementFromPoint(x, y);
if (clickedElement) {
clickedElement.dispatchEvent(event);
}
// 在点击后调用特定的函数
yourFunction(event); // 替换为你想要调用的函数
}
function yourFunction(event) {
console.log(event)
}
function autoRandomClick(interval) {
setInterval(function () {
var randomPosition = getRandomPosition();
simulateClick(randomPosition.x, randomPosition.y);
}, interval);
}
function getRandomPosition() {
var bodyRect = document.body.getBoundingClientRect();
var randomX = Math.floor(Math.random() * (bodyRect.width - 1)) + bodyRect.left;
var randomY = Math.floor(Math.random() * (bodyRect.height - 1)) + bodyRect.top;
return { x: randomX, y: randomY };
}
// 使用示例
autoRandomClick(1000);
02-22
5935
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交