Hello, I made a post asking this: Setar Interval every 1 second
And I have the following code:
iniciarVerificacao();
var verificar;
function iniciarVerificacao(){
if(verificar) clearInterval(verificar);
verificar=setInterval(function() {
if ($('#botao').is(':visible')){
console.log('botão vísivel');
clearInterval(verificar);
$('#botao').trigger('click');
console.log('botão removido');
iniciarVerificacao();
}else{
console.log('botão não vísivel');
iniciarVerificacao(); << Aqui seria para reiniciar e verificar novamente se o botão está vísivel (function iniciarVerificacao()
}
}, 1000);
}
What I wanted: What, he would check every 1 second if the button is visible on the page (after an hour (or varies, so the interval of 1 second) the page refreshes and the button appears), and when it appears, it clicks the button, and a time appears to appear again, and the scan starts again. And stay in this infinite loop, but the interval for when you are removing the button, summarizing:
1->Verifica se o botão está ativo
2->**Para o intervalo para remover o botão**
3->Ativa o intervalo novamente para ver se o botão está ativo (dentro de uma hora)
But I have some problems, when the button appears the script is stopped, I do not know if it will stop because the update page , or if it is stopped in else because if you leave the script running forever, it stops at the message: console.log ('button not visible');
Does anyone know what it can be?