UserScript Header Generator
Build a valid ==UserScript== metadata block with @match grammar and grant/connect checks.
Metadata fields
0 checksMetadata block
0 errors- All checks passed.
UserScript Header Generator composes a canonical ==UserScript== metadata block from a small form. Chrome-style @match patterns are validated against the scheme/host/path grammar, @include globs are checked, versions must be semver, and grant/connect consistency rules flag missing @connect entries or illegal @grant none combinations. Manager profiles for Tampermonkey, Violentmonkey and Greasemonkey set sensible API grants. Paste an existing block to hydrate the form, or wrap a script body in a strict-mode IIFE.
// @match https://example.com/*
The validator accepts exact schemes and hosts with a wildcard path, and rejects malformed host wildcards.
// @grant GM_xmlhttpRequest // @connect https://api.example.com
Cross-origin requests need both the grant and a matching @connect domain; missing connect is reported as a warning.
Tampermonkey → GM.setValue, GM.getValue, GM_xmlhttpRequest
Profiles prefill grants appropriate for the selected userscript manager.
Examples
Match pattern
https://*.example.com/*@match https://*.example.com/*A leading wildcard host is valid; a wildcard in the middle of a host is rejected.
Connected grant
GM_xmlhttpRequest + https://api.example.comgrant and @connect emittedCross-origin calls need both entries; without @connect a warning is shown.
Invalid grant mix
none + GM.setValuevalidation error@grant none disables the sandbox APIs, so it cannot be combined with GM_* grants.
About this tool
UserScript Header Generator writes a canonical ==UserScript== metadata block from form fields. Keys appear in the conventional order — name, namespace, version, description, author, match/include/exclude, connect, require/resource, grant, run-at — so the output is ready to paste into a .user.js file.
Validation covers the Chrome match-pattern grammar, @include globs, semver versions, http(s) URLs and manager consistency rules. A grant of GM_xmlhttpRequest without an @connect domain, or @grant none mixed with GM_* calls, is called out before you copy the block.
Manager profiles prefill grants for Tampermonkey, Violentmonkey and Greasemonkey. You can import an existing header to hydrate the form, optionally wrap a body in a strict-mode IIFE, and download the result. Everything happens in the browser.
What this tool does not do
- Validation checks grammar and consistency, not runtime support of a specific manager version.
- Only one script is edited at a time; imports replace the current fields.
- The optional body wrapper is a plain IIFE, not a build step or module bundler.
- Non-http(s) @connect URLs are rejected even where a manager might tolerate them.
- Nothing is uploaded or persisted; copy or download the finished block.
How to use this tool
Fill identity fields
Set name, namespace, semver version and a description; @name and @version are required.
Define targets
Enter one @match pattern per line (or @include globs) and any @exclude patterns.
Choose grants
Pick a manager profile or type GM_* grant names manually; add @connect domains for cross-origin calls.
Review checks
Errors block the output; warnings and info notes explain narrowing opportunities and manager-specific caveats.
Copy or download
Copy the generated block, import an existing header to edit it, or wrap a body into a full .user.js file.
Use cases
New userscript
Start from a validated template instead of copying an outdated gist.
Pattern debugging
Check why a script does not run on a site by validating the @match grammar.
Manager migration
Switch grant profiles when moving a script between Tampermonkey and Greasemonkey.
Header cleanup
Import an existing block and re-emit it in canonical order.
Header grammar highlights
| Token | Rule |
|---|---|
| @match | scheme://host/path with scheme http/https/ws/wss/ftp/file/*, wildcard host only as * or *.domain, path starting / |
| @include | Glob pattern; .tld is supported by managers as a top-level-domain suffix |
| @connect | Explicit http(s) host URLs; wildcards are not accepted |
| @version | Semver such as 1.2.3, with an optional leading v |
| @grant | One API name per line, or the literal none with no GM_* entries |
| @run-at | document-start, document-body, document-end, document-idle or context-menu |
Keys are padded to a fixed column width for readability; managers ignore the extra spaces.
Common mistakes
Mistake:Using @include where a @match pattern is required.
Fix:Prefer @match for precise scheme/host/path targeting; @include is a broader glob.
Mistake:Writing https://*/* for all hosts.
Fix:Use *://*/* or *.domain forms; a bare wildcard host triggers a warning outside file://.
Mistake:Forgetting @connect for cross-origin fetch.
Fix:Add the explicit https origin next to the GM_xmlhttpRequest grant.
Mistake:Combining @grant none with GM APIs.
Fix:Choose either the unsandboxed none mode or explicit GM grants, not both.
Mistake:Using a non-semver version such as 1.0.
Fix:Use three numeric components (1.0.0); a leading v is tolerated.
Frequently asked questions
What is the difference between @match and @include?
@match uses Chrome's strict scheme://host/path grammar and is the recommended, faster way to target pages. @include is a looser glob with conveniences such as .tld. The generator validates both, but prefers @match for precise targeting.
Why do I need @connect for fetch?
Userscript managers sandbox cross-origin requests. Granting GM_xmlhttpRequest or a fetch shim is not enough: each external origin must also be listed as an explicit @connect domain. The generator warns when a network grant has no @connect entries.
What does @grant none change?
It runs the script in the page context without GM API access. Because of that, it cannot be combined with GM_* grants; the generator reports that combination as an error.
Which @run-at value should I use?
document-idle is the safe default (after the page is ready). Use document-start when you must patch code before the page scripts run, document-body for early DOM access and context-menu for manager-triggered scripts.
How do I version and distribute the script?
Use a semver version such as 1.2.3 (a leading v is accepted). Optionally set @updateURL and @downloadURL to a stable raw file URL so managers can check for updates; both must be http(s) URLs.
Can I import an existing metadata block?
Yes. Paste the block into the script body field and press Import header. Repeated keys such as @match and @grant are collected, and the form regenerates them in canonical order with validation applied.
References & standards
Related tools
.env Secret Safety Linter
Validate .env syntax and spot likely leaked credentials or placeholder secrets.
.gitattributes Generator
Build .gitattributes rules for line endings, Git LFS, GitHub linguist marks and merge drivers — with a one-line explanation for every rule.
.htaccess Generator
Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth
2D Fluid Dynamics & Particle Physics Sandbox
A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.
A/B Test Sample Size Calculator
Compute required sample size per variant and test duration from baseline conversion rate, minimum detectable effect, alpha and power.
ABA Routing Number Validator
Validate 9-digit US ABA routing numbers with 3-7-1 Mod-10 breakdown.