Skip to content

Repository files navigation

spawncamp

A tiny library for userscripts that waits for elements to arrive in the DOM.

Installing

npm i spawncamp

Usage

import{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()

Development

To install dependencies:

bun install

Run tests:

bun test

Build:

bun run build.ts

About

A tiny library for userscripts that waits for elements to arrive in the DOM.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages