Skip to content

Instantly share code, notes, and snippets.

@Cside
Last active November 12, 2022 23:54
Show Gist options
  • Save Cside/8a1cea54fb08878d1a5a3bdad298fa20 to your computer and use it in GitHub Desktop.
Save Cside/8a1cea54fb08878d1a5a3bdad298fa20 to your computer and use it in GitHub Desktop.
const waitFor = (selector: string): Promise<NodeList> => {
return new Promise(resolve => {
const id = setInterval(() => {
const elems = document.querySelectorAll(selector);
if (elems.length >= 0) {
clearInterval(id);
resolve(elems);
}
}, 300);
});
};
function waitFor(selector) {
return new Promise(resolve => {
const id = setInterval(() => {
const elems = document.querySelectorAll(selector);
if (elems.length >= 0) {
clearInterval(id);
resolve(elems);
}
}, 200);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment