MCPcopy
hub / github.com/ocsjs/ocsjs / waitForElement

Function waitForElement

packages/scripts/src/utils/study.ts:47–54  ·  view source on GitHub ↗
(
	selector: string | { (): HTMLElement | undefined },
	opts?: { timeout_seconds?: number; check_period_ms?: number }
)

Source from the content-addressed store, hash-verified

45}
46
47export function waitForElement(
48 selector: string | { (): HTMLElement | undefined },
49 opts?: { timeout_seconds?: number; check_period_ms?: number }
50) {
51 return waitFor(() => {
52 return typeof selector === 'function' ? selector() : document.querySelector<HTMLElement>(selector);
53 }, opts);
54}
55
56export function waitFor<T>(predicate: () => T, opts?: { timeout_seconds?: number; check_period_ms?: number }) {
57 return new Promise<T>((resolve, reject) => {

Callers 15

onactiveFunction · 0.90
studyFunction · 0.90
oncompleteFunction · 0.90
studyFunction · 0.90
methodsFunction · 0.90
waitForLoadFunction · 0.90
waitForQuestionsFunction · 0.90
methodsFunction · 0.90
oncompleteFunction · 0.90
oncompleteFunction · 0.90
setFunction · 0.90
onstartFunction · 0.90

Calls 1

waitForFunction · 0.70

Tested by

no test coverage detected