Verifiable Bookmarklets
Generate, inspect and verify bookmarklets without executing them.
A bookmarklet is a normal browser bookmark that stores JavaScript instead of a web address. When you click it, the code runs on whatever page you are currently viewing, so you can automate small tasks on any site without installing an extension.
Source
Bookmarklet
Decoded JavaScript
Why verifiable bookmarklets
Bookmarklets are powerful: you can run JavaScript on almost any page by dragging a link to your bookmarks and clicking it. A verifiable bookmarklet keeps that workflow, while adding only a version, SHA-256 hash, optional source URL and, for Gists, the exact revision, so people can share one and prove that it came from the published source. Verification confirms the match, not the safety of the code.
Metadata
A verifiable bookmarklet is still a normal bookmarklet. It carries a small JavaScript comment immediately inside its wrapper, before the source runs:
/*bm:v1.1;sha=<sha256>;src=<url>;rev=<revision>*/bm:v1.1identifies the format. Olderbm:v1bookmarklets are still verified.shaidentifies the exact generated payload.srcoptionally points to the published source.revis the full Gist revision. It is required whensrcis a Gist and must be the revision the URL is pinned to. Other sources leave it out.
How verification works
The generator normalizes the source, creates the bookmarklet payload and calculates its SHA-256 before inserting the metadata comment. The validator decodes the bookmarklet, rebuilds the payload and compares the hashes. It never executes the code.
A match proves the source corresponds to the bookmarklet. It does not prove that the code is safe or trustworthy.
Version log
v1.1
/*bm:v1.1;sha=<sha256>;src=<url>;rev=<revision>*/- New
revfield with the full Gist revision. It is required for Gist sources and has to match the revision pinned insrc, so a bookmarklet always says which version of the Gist it was built from. - A Gist URL without a revision is pinned to the latest one. If the pasted URL is pinned and a newer revision exists, the generator and the verifier show a notice but keep the pinned revision.
- Non-Gist sources and pasted code use
bm:v1.1withoutrev. *insrcis escaped as%2Aso it cannot close the comment early.- The hash is unchanged: it still covers the payload without the metadata comment, and
bm:v1bookmarklets keep verifying.
- New
v1
/*bm:v1;sha=<sha256>;src=<url>*/shais the SHA-256 of the generated payload, calculated before the metadata comment is inserted.srcoptionally points to the published source.