WaitUntil

等待满足某种条件后执行,支持嵌套调用

Questo script non dovrebbe essere installato direttamente. È una libreria per altri script da includere con la chiave // @require https://update.greasyfork.org/scripts/412875/1177822/WaitUntil.js

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

Autore
wish king
Versione
0.1.3.2
Creato il
11/10/2020
Aggiornato il
13/04/2023
Dimensione
1,62 KB
Licenza
Non disponibile

等待满足某种条件后执行,这是什么库?
当你在写脚本时,有没有遇到过想等待某个元素加载完执行,或者等待jQuery加载完执行,或者满足多个条件后执行的情况?
如果有,那么这个脚本就是解决这个问题的
它有两个重要的参数,第一个是满足条件的函数,第二个是条件满足后执行的回调函数
支持嵌套调用


//使用示例

WaitUntil(function(){return typeof jQuery !=="undefined" && $(".test").length>0}, function(){
    alert($(".test").html());
});

//其他参数
//cond 满足条件的函数
//callback 条件满足后执行的回调函数
//interval 监听满足条件的时间间隔,单位毫秒,默认100
//trys 尝试次数,超过这个数值就停止监听,默认为300(因默认间隔是100毫秒,所以默认停止监控时间为300*100毫秒,即30秒)
//times 执行次数,默认执行1次,-1为无限次,0会忽略,等同于1次