Skip to content

Meta Headers

Every script starts with a Tampermonkey-style header:

text
// ==UserScript==
// @name         Copy as Markdown link
// @namespace    com.example.md-link
// @version      0.1.0
// @description  Wraps the focused text clip as a Markdown auto-link.
// @grant        utools.*
// @grant        globalNativeApi.*
// @match-clip   text
// ==/UserScript==

Required keys

KeyNotes
@nameDisplay name
@namespaceGlobally unique (reverse-DNS recommended); used as KV bucket and scriptData key
@versionSemVer
@descriptionOne-line summary

Optional keys

KeyDefaultNotes
@author
@homepageURL shown in the script manager
@iconURL or data:
@grantnoneRepeatable; only utools.* and globalNativeApi.* accepted
@requireURL to external lib; must include SRI
@match-clipallRepeatable: text / image / file
@run-aton-demandon-demand / background
@timeout30000ms; per-callback hard cap
@updateURLOverride default marketplace source; internal://<id> reserved for builtins
@tagRepeatable; powers marketplace filters

@grant

text
// @grant   utools.*
// @grant   globalNativeApi.*

Only these two tokens are accepted. No fine-grained subsets like @grant utools.copyText. See Grants & Sandbox for what's actually exposed.

@require + SRI

text
// @require   https://cdn.jsdelivr.net/npm/qrcode-svg@1.1.0/dist/qrcode.min.js#sha256-AbCd…
  • Whitelisted hosts: registry.npmmirror.com, cdn.jsdelivr.net, unpkg.com.

  • SRI suffix #sha256-… / #sha384-… / #sha512-… is mandatory.

  • Compute it:

    bash
    curl -sL "<url>" | openssl dgst -sha256 -binary | base64

@match-clip vs options.matchClip

  • @match-clip filters the whole script — if no current clip matches, none of the script's commands appear.
  • options.matchClip on registerMenuCommand further narrows a single command.

The two intersect: a command is only available when both pass.