Skip to content

Add userScripts.execute sample#1687

Open
KirtiRamchandani wants to merge 1 commit into
GoogleChrome:mainfrom
KirtiRamchandani:add/user-scripts-execute-sample
Open

Add userScripts.execute sample#1687
KirtiRamchandani wants to merge 1 commit into
GoogleChrome:mainfrom
KirtiRamchandani:add/user-scripts-execute-sample

Conversation

@KirtiRamchandani

Copy link
Copy Markdown

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Samples for userScripts.execute

1 participant