Simple WaitForKeyElement

Library that Exports my simplified vanilla JS version of WaitForKeyElement, which is a simple async function that returns a Promise that resolves to an element by a given selector, when that element is found

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greasyfork.org/scripts/511024/1460585/Simple%20WaitForKeyElement.js

Author
1N07
Version
1.0.1
Created
2024-10-01
Updated
2024-10-07
License
Unlicense

Library that Exports my simplified vanilla JS version of WaitForKeyElement

which is a simple async function that returns a Promise that resolves to an element by a given selector, when that element is found

Usage:

WaitForKeyElement(querySelectorString, optionalTimeoutInMilliseconds)

Example 1:

WaitForKeyElement('#someElement', 10000).then((foundElement) => {
  //do things with foundElement
});

Example 2:

//in async context*
const foundElement = await WaitForKeyElement('#someElement'));
//do things with foundElement