Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vaaski/spawncamp
A tiny library for userscripts that waits for elements to arrive in the DOM.
https://github.com/vaaski/spawncamp
bun greasemonkey userscript
Last synced: 22 days ago
JSON representation
A tiny library for userscripts that waits for elements to arrive in the DOM.
- Host: GitHub
- URL: https://github.com/vaaski/spawncamp
- Owner: vaaski
- Created: 2024-09-10T12:19:14.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-09-10T13:38:57.000Z (about 2 months ago)
- Last Synced: 2024-10-02T05:42:19.802Z (about 1 month ago)
- Topics: bun, greasemonkey, userscript
- Language: TypeScript
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# spawncamp
A tiny library for userscripts that waits for elements to arrive in the DOM.
## Installing
```bash
npm i spawncamp
```## Usage
```ts
import { Spawncamp } from "spawncamp"const camp = new Spawncamp()
// Awaits the button element to arrive in the DOM once
const button = await camp.once("button")button.addEventListener("click", () => {
console.log("Clicked!")
})// Calls the callback every time an element matching the selector arrives in the DOM
const remove = camp.on("button", (element) => {
console.log("New button just dropped", element)
})// Removes the observer for that selector
remove()// Stops observing the DOM entirely
camp.stop()
```## Development
To install dependencies:
```bash
bun install
```Run tests:
```bash
bun test
```Build:
```bash
bun run build.ts
```This project was created using `bun init` with bun v1.1.27.
It uses [Biome](https://biomejs.dev) for formatting and linting.