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

FormatNoneSHANot generated yetSourceManual sourceMetadataNoneSizeNo bookmarklet yet
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.1 identifies the format. Older bm:v1 bookmarklets are still verified.
  • sha identifies the exact generated payload.
  • src optionally points to the published source.
  • rev is the full Gist revision. It is required when src is 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

  1. v1.1

    /*bm:v1.1;sha=<sha256>;src=<url>;rev=<revision>*/
    • New rev field with the full Gist revision. It is required for Gist sources and has to match the revision pinned in src, 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.1 without rev.
    • * in src is escaped as %2A so it cannot close the comment early.
    • The hash is unchanged: it still covers the payload without the metadata comment, and bm:v1 bookmarklets keep verifying.
  2. v1

    /*bm:v1;sha=<sha256>;src=<url>*/
    • sha is the SHA-256 of the generated payload, calculated before the metadata comment is inserted.
    • src optionally points to the published source.