MCPcopy Index your code
hub / github.com/hoothin/UserScripts / waitForElement

Function waitForElement

Pagetual/pagetual.user.js:12394–12412  ·  view source on GitHub ↗
(sel, doc, maxTime)

Source from the content-addressed store, hash-verified

12392 }
12393
12394 async function waitForElement(sel, doc, maxTime) {
12395 if (!sel) return null;
12396 return new Promise((resolve) => {
12397 let passedTime = 0;
12398 let checkInv = setInterval(() => {
12399 let result = getElement(sel, doc, null, true);
12400 if (result) {
12401 clearInterval(checkInv);
12402 resolve(result);
12403 } else if (maxTime) {
12404 passedTime += 100;
12405 if (passedTime >= maxTime) {
12406 clearInterval(checkInv);
12407 resolve(result);
12408 }
12409 }
12410 }, 100);
12411 });
12412 }
12413
12414 async function waitForElements(sel, doc, maxTime) {
12415 if (!sel) return null;

Callers 4

clickActionFunction · 0.85
enterActionFunction · 0.85
inputActionFunction · 0.85
cloneStatusFunction · 0.85

Calls 2

getElementFunction · 0.85
resolveFunction · 0.50

Tested by

no test coverage detected