Skip to content

fix: auto-add --disable-extensions-except for --load-extension in args#357

Open
onepaperbox wants to merge 1 commit into
CloakHQ:mainfrom
onepaperbox:fix/auto-disable-extensions-except
Open

fix: auto-add --disable-extensions-except for --load-extension in args#357
onepaperbox wants to merge 1 commit into
CloakHQ:mainfrom
onepaperbox:fix/auto-disable-extensions-except

Conversation

@onepaperbox

Copy link
Copy Markdown

Problem

When Chrome extensions are loaded via --load-extension in args/extra_args (e.g., through CloakBrowser-Managers launch_args), extensions fail to load because Playwrights default --disable-extensions flag blocks all extensions.

The extension_paths parameter (added in #210) already handles this correctly by injecting both --load-extension and --disable-extensions-except. However, when --load-extension is passed via args directly (as CloakBrowser-Manager does), the companion --disable-extensions-except flag 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 processing extension_paths, check if --load-extension exists in the seen dict (from extra_args) but --disable-extensions-except does not. If so, automatically inject the companion flag with the same paths.

This makes extension loading work seamlessly via either:

  1. extension_paths=["/path/to/ext"] — existing, unchanged behavior
  2. args=["--load-extension=/path/to/ext"] — now auto-fixed

Files changed:

  • cloakbrowser/browser.py — Python build_args() — auto-inject companion flag
  • js/src/args.ts — JS buildArgs() — same logic
  • tests/test_build_args.py — 5 new Python tests
  • js/tests/extension-loading.test.ts — 4 new JS tests

Testing

All 43 Python tests pass, all 5 JS tests pass:

tests/test_build_args.py::test_load_extension_auto_adds_companion PASSED
tests/test_build_args.py::test_load_extension_multi_path_auto_adds_companion PASSED
tests/test_build_args.py::test_load_extension_no_duplicate_companion PASSED
tests/test_build_args.py::test_no_companion_without_load_extension PASSED
tests/test_build_args.py::test_extension_paths_still_works PASSED

js/tests/extension-loading.test.ts (5 tests) PASSED

Backward Compatibility

  • Existing extension_paths parameter behavior is unchanged (the elif only fires when extension_paths is falsy)
  • If users already manually include --disable-extensions-except in their args, no duplication occurs (checked via seen dict)
  • No API changes, no new parameters

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
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.

2 participants