gpt4 book ai didi

javascript - Greasemonkey 脚本中的间隔不等待

转载 作者:行者123 更新时间:2023-11-30 13:04:32 25 4
gpt4 key购买 nike

我使用 Greasemonkey 每 100 秒单击一次页面上的按钮。到目前为止,我能够让 JS 单击按钮,但它不会等待 100 秒。

我没有收到任何错误,但 setInterval 只是在继续之前没有等待。谢谢!

代码:

console.log('script start');
var int =self.setInterval(function(){clickConfirmButton(e)},100000);
console.log('script start waiting');
function clickConfirmButton(e) {
var buttons = document.getElementsByTagName('button');
var clicked = false;
for (var index=0; index < buttons.length; index++){
if(buttons[index].textContent == "check"){
buttons[index].click();
clicked = true;
break;
}
}
if(!clicked){
setTimeout("window.location.reload()",300*1000);
}
}
clickConfirmButton();

最佳答案

最后你有这个函数调用:

clickConfirmButton();

它完全绕过了 100 秒计时器。删除或注释掉该行。

关于javascript - Greasemonkey 脚本中的间隔不等待,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16159465/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com