These are libraries for use in userscripts by developers.
Using waitForElement.js
as an example – replace the filename in instructions
with the library you would like to use.
Add a @require
entry to metadata of the userscript:
// @require https://github.com/rybak/userscript-libs/raw/<commit>/waitForElement.js
Replace the <commit>
placeholder with the hash of the commit
that you want to use.
If you want to publish the userscript on Greasy Fork, you'll have to follow their policy on external scripts. This can be done using the JSDelivr CDN or other content delivery networks approved by Greasy Fork. Greasy Fork (rightly) doesn't allow using a branch or a tag.
// @require https://cdn.jsdelivr.net/gh/rybak/userscript-libs@<commit>/waitForElement.js
Provides a way for userscripts to wait for native HTML or SVG elements to be
loaded, before performing some operation on them. Function waitForElement
takes a selector as a parameter and returns a
Promise
. The returned Promise
gets resolved with an
Element
corresponding to the given selector, when the element
appears in the document. Usage:
waitForElement('#targetId').then(target => {
// extract information from `target`:
const text = target.innerText;
// add your own elements to `target`:
target.append("Hello, world!");
});