From 0a8d8f09c88c7b649362abea63e32aa684332e49 Mon Sep 17 00:00:00 2001 From: Oj Date: Thu, 22 Apr 2021 21:02:11 +0100 Subject: [PATCH] [PCCompat > Util] Add sleep, waitFor --- moduleWrappers/powercord/util.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/moduleWrappers/powercord/util.js b/moduleWrappers/powercord/util.js index ae282b7..2d3f00e 100644 --- a/moduleWrappers/powercord/util.js +++ b/moduleWrappers/powercord/util.js @@ -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 }; \ No newline at end of file