fix: auto-add --disable-extensions-except for --load-extension in args#357
Open
onepaperbox wants to merge 1 commit into
Open
fix: auto-add --disable-extensions-except for --load-extension in args#357onepaperbox wants to merge 1 commit into
onepaperbox wants to merge 1 commit into
Conversation
When Chrome extensions are loaded via --load-extension in args/extra_args (e.g., through CloakBrowser-Manager's launch_args), extensions fail to load because Playwright's default --disable-extensions flag blocks them. The extension_paths parameter already handles this correctly by injecting both flags. However, when --load-extension is passed via args directly, the companion --disable-extensions-except was missing. This fix detects --load-extension in the seen dict (from extra_args) and auto-injects --disable-extensions-except with the same paths, making extension loading work seamlessly via either path. Fixes CloakHQ/CloakBrowser-Manager#30 Related CloakHQ/CloakBrowser-Manager#37
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.
Problem
When Chrome extensions are loaded via
--load-extensioninargs/extra_args(e.g., through CloakBrowser-Managerslaunch_args), extensions fail to load because Playwrights default--disable-extensionsflag blocks all extensions.The
extension_pathsparameter (added in #210) already handles this correctly by injecting both--load-extensionand--disable-extensions-except. However, when--load-extensionis passed viaargsdirectly (as CloakBrowser-Manager does), the companion--disable-extensions-exceptflag is not automatically injected, leaving extensions broken.This affects all CloakBrowser-Manager users who try to load extensions via
launch_args. Related issues:Fix
In
build_args(), after processingextension_paths, check if--load-extensionexists in theseendict (fromextra_args) but--disable-extensions-exceptdoes not. If so, automatically inject the companion flag with the same paths.This makes extension loading work seamlessly via either:
extension_paths=["/path/to/ext"]— existing, unchanged behaviorargs=["--load-extension=/path/to/ext"]— now auto-fixedFiles changed:
cloakbrowser/browser.py— Pythonbuild_args()— auto-inject companion flagjs/src/args.ts— JSbuildArgs()— same logictests/test_build_args.py— 5 new Python testsjs/tests/extension-loading.test.ts— 4 new JS testsTesting
All 43 Python tests pass, all 5 JS tests pass:
Backward Compatibility
extension_pathsparameter behavior is unchanged (theelifonly fires whenextension_pathsis falsy)--disable-extensions-exceptin their args, no duplication occurs (checked viaseendict)