{"id":"e63e04b4-c35a-4631-b7a2-fb6b7f410acf","shortId":"CZTrPB","kind":"skill","title":"Develop Userscripts","tagline":"Skills skill by Xixu Me","description":"Userscript work usually breaks at the runtime and metadata boundary, not in the page logic. Choose the runtime first, declare the minimum permissions up front, then debug in the environment where the script actually runs.\n\n## When to Use\n\nUse this skill for:\n\n- writing or fixing a Tampermonkey or ScriptCat userscript\n- debugging injection timing, missing permissions, CSP workarounds, update checks, or `GM_*` behavior\n- deciding between a portable foreground script and ScriptCat-only `@background` or `@crontab`\n- adding config UI with `==UserConfig==`\n- packaging a ScriptCat `==UserSubscribe==` bundle or preparing a CloudCat-compatible script\n\nDo not use this skill for full browser extension development or general browser automation outside userscript managers.\n\n## Runtime Selection\n\n```dot\ndigraph userscript_runtime {\n    \"Need page DOM or page context?\" [shape=diamond];\n    \"Need persistent or scheduled work?\" [shape=diamond];\n    \"Need to install many scripts as one package?\" [shape=diamond];\n    \"Portable foreground script\" [shape=box];\n    \"ScriptCat background or crontab script\" [shape=box];\n    \"ScriptCat subscription package\" [shape=box];\n\n    \"Need page DOM or page context?\" -> \"Portable foreground script\" [label=\"yes\"];\n    \"Need page DOM or page context?\" -> \"Need persistent or scheduled work?\" [label=\"no\"];\n    \"Need persistent or scheduled work?\" -> \"ScriptCat background or crontab script\" [label=\"yes\"];\n    \"Need persistent or scheduled work?\" -> \"Need to install many scripts as one package?\" [label=\"no\"];\n    \"Need to install many scripts as one package?\" -> \"ScriptCat subscription package\" [label=\"yes\"];\n    \"Need to install many scripts as one package?\" -> \"Portable foreground script\" [label=\"no\"];\n}\n```\n\n## Preflight\n\n- Confirm the manager and browser. On Manifest V3 browsers, ScriptCat may require `Allow User Scripts` or browser developer mode before scripts run.\n- Decide page script versus background script before writing code. ScriptCat background scripts cannot touch the DOM.\n- Start with metadata, not implementation: `@match`, `@grant`, `@connect`, `@run-at`, and any update URLs.\n- Prefer portable `==UserScript==` patterns for ordinary page scripts. Only switch to ScriptCat-only headers when the requested behavior actually needs them.\n\n## Workflow\n\n1. Choose the runtime and metadata first.\n2. Declare the smallest permission surface that fits the task.\n3. Implement against the runtime you chose.\n4. Debug where the code really runs.\n   - Foreground scripts: page console plus manager logs.\n   - ScriptCat background scripts: run log first, then `background.html` for real-environment debugging.\n5. Publish with the right update model.\n   - Normal scripts: keep `@version` accurate and add `@updateURL` or `@downloadURL` only when needed.\n   - Subscription bundles: use `==UserSubscribe==`, HTTPS URLs, and subscription-level `@connect`.\n\n## Quick Reference\n\n| Intent                               | Default choice                               | Watch for                                                                 |\n| ------------------------------------ | -------------------------------------------- | ------------------------------------------------------------------------- |\n| Page UI, DOM scraping, page patching | Portable `==UserScript==`                    | `@match`, `@grant`, `@run-at`, CSP-sensitive injection                    |\n| Cross-origin API access              | `GM_xmlhttpRequest` with explicit `@connect` | Missing hosts, cookie behavior differences, user authorization            |\n| Long-running worker                  | ScriptCat `@background`                      | No DOM, must return `Promise` for async work                              |\n| Scheduled task                       | ScriptCat `@crontab`                         | Only first `@crontab` counts, prefer 5-field cron, avoid interval overlap |\n| User-editable settings               | `==UserConfig==` plus `GM_getValue`          | Block placement and `group.key` naming                                    |\n| Silent bundle install and updates    | `==UserSubscribe==`                          | HTTPS, `user.sub.js`, subscription `connect` overrides child scripts      |\n\n## Common Mistakes\n\n- Missing `@grant` for APIs the script actually uses.\n- Missing `@connect` for hosts used by `GM_xmlhttpRequest` or `GM_cookie`.\n- Treating `@include` as a better default than `@match` for ordinary host targeting.\n- Using DOM APIs inside ScriptCat background or cron scripts.\n- Returning from a ScriptCat background script before async GM work is truly finished.\n- Mixing `==UserScript==` and `==UserSubscribe==` packaging concepts.\n- Putting `==UserConfig==` in the wrong place or reading config keys without the `group.key` name.\n- Assuming Tampermonkey and ScriptCat storage, notification, or request behavior is identical.\n\n## References\n\n- [`references/metadata-and-api-map.md`](./references/metadata-and-api-map.md)\n- [`references/scriptcat-extensions.md`](./references/scriptcat-extensions.md)","tags":["develop","userscripts","skills","xixu-me"],"capabilities":["skill","source-xixu-me","category-skills"],"categories":["skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/xixu-me/skills/develop-userscripts","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"install_from":"skills.sh"}},"qualityScore":"0.300","qualityRationale":"deterministic score 0.30 from registry signals: · indexed on skills.sh · published under xixu-me/skills","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill:v1","enrichmentVersion":1,"enrichedAt":"2026-04-23T23:40:14.410Z","embedding":null,"createdAt":"2026-04-18T20:24:32.564Z","updatedAt":"2026-04-23T23:40:14.410Z","lastSeenAt":"2026-04-23T23:40:14.410Z","tsv":"'/references/metadata-and-api-map.md':585 '/references/scriptcat-extensions.md':587 '1':319 '2':326 '3':336 '4':343 '5':370,465 'access':429 'accur':381 'actual':41,315,505 'ad':83 'add':383 'allow':255 'api':428,502,532 'assum':572 'async':454,546 'author':441 'autom':113 'avoid':468 'background':80,154,195,269,275,358,447,535,543 'background.html':364 'behavior':69,314,438,580 'better':522 'block':479 'boundari':17 'box':152,159,164 'break':11 'browser':107,112,247,251,259 'bundl':92,391,485 'cannot':277 'category-skills' 'check':66 'child':495 'choic':405 'choos':23,320 'chose':342 'cloudcat':97 'cloudcat-compat':96 'code':273,347 'common':497 'compat':98 'concept':557 'config':84,566 'confirm':243 'connect':288,400,434,493,508 'consol':353 'context':128,170,181 'cooki':437,517 'count':463 'cron':467,537 'crontab':82,156,197,459,462 'cross':426 'cross-origin':425 'csp':63,422 'csp-sensit':421 'debug':34,58,344,369 'decid':70,265 'declar':27,327 'default':404,523 'develop':1,109,260 'diamond':130,137,147 'differ':439 'digraph':120 'dom':125,167,178,280,410,449,531 'dot':119 'downloadurl':386 'edit':473 'environ':37,368 'explicit':433 'extens':108 'field':466 'finish':551 'first':26,325,362,461 'fit':333 'fix':52 'foreground':74,149,172,238,350 'front':32 'full':106 'general':111 'getvalu':478 'gm':68,430,477,513,516,547 'grant':287,417,500 'group.key':482,570 'header':310 'host':436,510,528 'https':394,490 'ident':582 'implement':285,337 'includ':519 'inject':59,424 'insid':533 'instal':140,208,218,231,486 'intent':403 'interv':469 'keep':379 'key':567 'label':174,187,199,214,227,240 'level':399 'log':356,361 'logic':22 'long':443 'long-run':442 'manag':116,245,355 'mani':141,209,219,232 'manifest':249 'match':286,416,525 'may':253 'metadata':16,283,324 'minimum':29 'miss':61,435,499,507 'mistak':498 'mix':552 'mode':261 'model':376 'must':450 'name':483,571 'need':123,131,138,165,176,182,189,201,206,216,229,316,389 'normal':377 'notif':577 'one':144,212,222,235 'ordinari':301,527 'origin':427 'outsid':114 'overlap':470 'overrid':494 'packag':88,145,162,213,223,226,236,556 'page':21,124,127,166,169,177,180,266,302,352,408,412 'patch':413 'pattern':299 'permiss':30,62,330 'persist':132,183,190,202 'place':563 'placement':480 'plus':354,476 'portabl':73,148,171,237,297,414 'prefer':296,464 'preflight':242 'prepar':94 'promis':452 'publish':371 'put':558 'quick':401 'read':565 'real':367 'real-environ':366 'realli':348 'refer':402,583 'references/metadata-and-api-map.md':584 'references/scriptcat-extensions.md':586 'request':313,579 'requir':254 'return':451,539 'right':374 'run':42,264,290,349,360,419,444 'run-at':289,418 'runtim':14,25,117,122,322,340 'schedul':134,185,192,204,456 'scrape':411 'script':40,75,99,142,150,157,173,198,210,220,233,239,257,263,267,270,276,303,351,359,378,496,504,538,544 'scriptcat':56,78,90,153,160,194,224,252,274,308,357,446,458,534,542,575 'scriptcat-on':77,307 'select':118 'sensit':423 'set':474 'shape':129,136,146,151,158,163 'silent':484 'skill':3,4,48,104 'smallest':329 'source-xixu-me' 'start':281 'storag':576 'subscript':161,225,390,398,492 'subscription-level':397 'surfac':331 'switch':305 'tampermonkey':54,573 'target':529 'task':335,457 'time':60 'touch':278 'treat':518 'truli':550 'ui':85,409 'updat':65,294,375,488 'updateurl':384 'url':295,395 'use':45,46,102,392,506,511,530 'user':256,440,472 'user-edit':471 'user.sub.js':491 'userconfig':87,475,559 'userscript':2,8,57,115,121,298,415,553 'usersubscrib':91,393,489,555 'usual':10 'v3':250 'version':380 'versus':268 'watch':406 'without':568 'work':9,135,186,193,205,455,548 'workaround':64 'worker':445 'workflow':318 'write':50,272 'wrong':562 'xixu':6 'xmlhttprequest':431,514 'yes':175,200,228","prices":[{"id":"0e20c069-3e29-41b2-800b-cfdcf9adc62e","listingId":"e63e04b4-c35a-4631-b7a2-fb6b7f410acf","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"xixu-me","category":"skills","install_from":"skills.sh"},"createdAt":"2026-04-18T20:24:32.564Z"}],"sources":[{"listingId":"e63e04b4-c35a-4631-b7a2-fb6b7f410acf","source":"github","sourceId":"xixu-me/skills/develop-userscripts","sourceUrl":"https://github.com/xixu-me/skills/tree/main/skills/develop-userscripts","isPrimary":false,"firstSeenAt":"2026-04-18T22:19:15.140Z","lastSeenAt":"2026-04-23T18:57:54.755Z"},{"listingId":"e63e04b4-c35a-4631-b7a2-fb6b7f410acf","source":"skills_sh","sourceId":"xixu-me/skills/develop-userscripts","sourceUrl":"https://skills.sh/xixu-me/skills/develop-userscripts","isPrimary":true,"firstSeenAt":"2026-04-18T20:24:32.564Z","lastSeenAt":"2026-04-23T23:40:14.410Z"}],"details":{"listingId":"e63e04b4-c35a-4631-b7a2-fb6b7f410acf","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"xixu-me","slug":"develop-userscripts","source":"skills_sh","category":"skills","skills_sh_url":"https://skills.sh/xixu-me/skills/develop-userscripts"},"updatedAt":"2026-04-23T23:40:14.410Z"}}