Fix Chrome script injection API detection#1
Open
fkuefler wants to merge 1 commit intoadervark:fix/service-worker-lifecyclefrom
Open
Fix Chrome script injection API detection#1fkuefler wants to merge 1 commit intoadervark:fix/service-worker-lifecyclefrom
fkuefler wants to merge 1 commit intoadervark:fix/service-worker-lifecyclefrom
Conversation
Author
|
Really appreciate your fix. Not sure if the original repo owner is ever going to merge your PR, but if he does this fixes a small issue I was having. |
|
Hello @fkuefler
|
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.
Summary
This fixes a Chrome runtime failure when submitting through the extension.
Chrome can expose a
browsernamespace, so checking onlytypeof browser !== 'undefined'is not a reliable Firefox check. In Chrome, that caused the extension to callbrowser.tabs.executeScript, which is not available there under Manifest V3, leading to:TypeError: browser.tabs.executeScript is not a functionWhat changed
browser.tabs.executeScriptonly when that specific function existschrome.scripting.executeScript, which is the correct Chrome Manifest V3 pathself.chrome = browsershim from the affected filesFiles changed
src/handleSubmit.tssrc/injectedScript.tsVerification
npm run webpack./create-zip.shbrowser.tabs.executeScripterror no longer occurred