1

我正在使用 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();
4

1 回答 1

3

最后你有这个函数调用:

clickConfirmButton();

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

于 2013-04-23T01:46:33.497 回答