feat: improve apis + add animated background and assessment average plugins

This commit is contained in:
SethBurkart123
2025-03-30 13:17:19 +11:00
parent aeaf5d9e59
commit b8d8b108c3
11 changed files with 189 additions and 268 deletions
+12 -1
View File
@@ -5,14 +5,25 @@ export async function waitForElm(
selector: string,
usePolling: boolean = false,
interval: number = 100,
maxIterations?: number
): Promise<Element> {
if (usePolling) {
return new Promise((resolve) => {
return new Promise((resolve, reject) => {
let iterations = 0;
if (maxIterations) {
iterations = 0;
}
const checkForElement = () => {
const element = document.querySelector(selector)
if (element) {
resolve(element)
} else {
if (maxIterations) {
iterations++;
if (iterations >= maxIterations) {
reject(new Error("Element not found"));
}
}
setTimeout(checkForElement, interval)
}
}