Repository navigation
Conversation
Registered user scripts are injected into matching frames of tracked tabs as each frame commits a navigation, honoring matches, excludeMatches, includeGlobs, excludeGlobs, allFrames and runAt. USER_SCRIPT world scripts run in the extension's isolated world through tabs.executeScript, so they can message the extension over runtime.onMessage/onConnect; MAIN world scripts run in the page. Injection requires a matching host permission, and file sources must resolve inside the extension.
Each extension may create one offscreen document, hosted in a hidden window that loads the extension page. runtime.getContexts reports it as an OFFSCREEN_DOCUMENT context.
…named or bundled resolvePreloadPath falls back to __dirname, but the bundled entry lives in dist/cjs or dist/esm while the preload is built to dist/. Check both locations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds two APIs that MV3-era userscript managers depend on.
chrome.userScripts:
register,update,unregister,getScriptsandconfigureWorld. Registered scripts are injected into matching frames of tracked tabs as each frame commits a navigation, honoringmatches,excludeMatches,includeGlobs,excludeGlobs,allFramesandrunAt.USER_SCRIPTworld scripts run in the extension's isolated world throughtabs.executeScript, so they can message the extension.MAINworld scripts run in the page.filesources must resolve inside the extension.chrome.offscreen:
createDocument,closeDocumentandhasDocument. Each extension may have one offscreen document, hosted in a hidden window.runtime.getContextsreports it asOFFSCREEN_DOCUMENT.Known limitations
runtime.onMessage/onConnect;onUserScriptMessage/onUserScriptConnectare not fired.configureWorldis accepted but has no effect, so CSP and messaging aren't configurable.Testing: new fixture extension and specs for both APIs; the full suite passes (68/68). Also checked manually with a real userscript manager (an MV2 build): its runtime registered through
userScriptsand a@grant nonescript ran in the page.