Menu

#1687 Add userScripts.execute sample

open
nobody
None
2026-05-25
2026-05-25
Anonymous
No

Originally created by: KirtiRamchandani

Problem

The userScripts sample only showed persistent registration/update flows, while [#1482] asks for sample coverage of chrome.userScripts.execute() for dynamic one-off code.

Root cause

userScripts.execute() was added after the original sample and needs a UserScriptInjection target plus Chrome 135+, so the existing Chrome 120 sample never demonstrated it.

Solution

  • Raise the sample minimum Chrome version to 135.
  • Add a Run once section that executes code in an open https://example.com/ tab with chrome.userScripts.execute() and displays the injection result or error.
  • Reuse the existing script source construction for registered file/custom code.
  • Update README instructions and fix the API docs link.

Tests run

  • npx eslint --no-warn-ignored api-samples/userScripts/options.js --quiet
  • npx prettier --check api-samples/userScripts/manifest.json api-samples/userScripts/options.html api-samples/userScripts/options.js api-samples/userScripts/options.css api-samples/userScripts/README.md
  • git diff --check HEAD~1..HEAD
  • Node VM smoke test for options.js registration and execute payload

Fixes [#1482]

Related

Tickets: #1482

Discussion


Log in to post a comment.