A tiny library for userscripts that waits for elements to arrive in the DOM.
npm i spawncampimport{Spawncamp}from"spawncamp"constcamp=newSpawncamp()// Awaits the button element to arrive in the DOM onceconstbutton=awaitcamp.once("button")button.addEventListener("click",()=>{console.log("Clicked!")})// Calls the callback every time an element matching the selector arrives in the DOMconstremove=camp.on("button",(element)=>{console.log("New button just dropped",element)})// Removes the observer for that selectorremove()// Stops observing the DOM entirelycamp.stop()To install dependencies:
bun installRun tests:
bun testBuild:
bun run build.ts