save_script
Save a reusable userscript with match patterns and manual or auto run modes. Reusing an existing name replaces the script and increments its version.
Instructions
Save a reusable userscript. code is the body of a function: plain JavaScript with full DOM access in the page, no imports; use return to hand a result back to run_script. These GM_ APIs work in Tether and in Tampermonkey: GM_addStyle, GM_getValue, GM_setValue, GM_deleteValue, GM_listValues, GM_xmlhttpRequest, GM_openInTab, GM_setClipboard, GM_notification, unsafeWindow. run=manual puts a Run button in the popup (and a menu command in Tampermonkey); run=auto runs on every matching page load. Saving an existing name replaces it and bumps its version.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"name": "<name>",
"matches": "<matches>",
"code": "<code>"
},
"name": "save_script"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| run | No | ||
| code | Yes | ||
| name | Yes | ||
| runAt | No | For run=auto. Default document-idle. | |
| matches | Yes | Match patterns, e.g. ["https://mail.example.com/*"]. | |
| description | No |