MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / sleep

Function sleep

scripts/fb_autoRemoveSpamPostGroup_main.js:159–172  ·  view source on GitHub ↗
(time, cancelFn)

Source from the content-addressed store, hash-verified

157 }
158
159 function sleep(time, cancelFn) {
160 return new Promise((resolve) => {
161 const timeout = setTimeout(resolve, time);
162 if (cancelFn) {
163 const interval = setInterval(() => {
164 if (cancelFn()) {
165 clearInterval(interval);
166 clearTimeout(timeout);
167 resolve();
168 }
169 }, 100);
170 }
171 });
172 }
173
174 function onElementsAdded(selector, callback, once) {
175 let nodes = document.querySelectorAll(selector);

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected