Opinionated, slim and fast boilerplate for creating userscripts
Bundles everything into a single
user.index.jsPreloaded with Violentmonkey types
Serve userscript over HTTP for development
Inline styles with
loadStylecompiler macro andinjectStyleruntime<style>tag creator// transforms thisinjectStyle(loadStyle("styles/main.css"))// into thisinjectStyle("*{color:red!important}")
Interactive customizer for setup
❯ bun run customize ┌ userscript-template setup wizard │ ◇ What should the userscript be called? │ epic-userscript │ ◇ Describe it. │ makes the web more usable │ [...]Automatic userscript metablock generation from package.json fields
No dependencies, fully utilizing bun's fast toolchain (apart from customizer prompts)
Opinionated ESLint + ESLint-Stylistic configuration
Builds quickly on every GitHub push and releases as artifact
- Install bun
- Clone this repo or generate from template
- Run
bun install - Run
bun run customize
The build script takes two optional flags:
--minify,-mto minify the output--watch,-wto watch for changes and rebuild
- Run
bun run dev - Open
http://localhost:3000in your browser - Click the userscript link. It should automatically open your userscript manager.
- Run
bun run build - Output should be at
out/index.user.js
Toggle injected styles with userscript menu item
import{loadStyle}from"~~/build/styles"with{type: "macro"}import{injectStyle}from"~~/userscript/util/inject-style"conststyle=loadStyle("styles/main.css")letremoveInjection: (()=>void)|undefined=injectStyle(style)GM.registerMenuCommand("Toggle CSS injection",()=>{if(removeInjection){removeInjection()removeInjection=undefined}else{removeInjection=injectStyle(style)}},{icon: "https://www.google.com/s2/favicons?sz=64&domain=google.com",autoClose: false,title: "Example menu command",},)
- Spawncamp - my userscript utility toolbox
- Violentmonkey
- Violentmonkey API Documentation
GNU GPLv3