[PCCompat > Util] Add sleep, waitFor

This commit is contained in:
Ducko 2021-04-22 21:02:11 +01:00 committed by Lexi Sother
parent 27847ca0b6
commit 0a8d8f09c8
No known key found for this signature in database
GPG Key ID: 355968D14144B739
1 changed files with 13 additions and 0 deletions

View File

@ -1,3 +1,16 @@
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
module.exports = {
sleep,
waitFor: async (query) => {
while (true) {
const el = document.querySelector(query);
if (el) return el;
await sleep(5);
}
},
...goosemodScope.reactUtils // Export GooseMod React utils
};