Skip to content

feat(browse): support Chrome extensions via BROWSE_EXTENSIONS_DIR#315

Open
yinanli1917-cloud wants to merge 1 commit intogarrytan:mainfrom
yinanli1917-cloud:feat/browse-extension-support
Open

feat(browse): support Chrome extensions via BROWSE_EXTENSIONS_DIR#315
yinanli1917-cloud wants to merge 1 commit intogarrytan:mainfrom
yinanli1917-cloud:feat/browse-extension-support

Conversation

@yinanli1917-cloud
Copy link

Summary

  • Add BROWSE_EXTENSIONS_DIR environment variable to load unpacked Chrome extensions into browse's Chromium instance
  • When set, browse launches in headed mode with the window off-screen (--window-position=-9999,-9999) since Chrome extensions require a headed browser
  • When unset, behavior is identical to current — pure headless, zero side effects

Why

Browse users often have Chrome extensions that improve their browsing workflow — ad blockers (fewer tokens wasted on ad-heavy pages), accessibility tools, custom header managers, etc. Currently there's no way to bring these into browse's Chromium.

This is a single env var, zero config files, fully opt-in. One line in .zshrc and it just works.

Change

One file, 22 lines added: browse/src/browser-manager.ts

const extensionsDir = process.env.BROWSE_EXTENSIONS_DIR;
if (extensionsDir) {
  // headed + off-screen window (extensions don't work in headless)
  // --load-extension + --disable-extensions-except
}

Test plan

  • BROWSE_EXTENSIONS_DIR unset → headless as before, no regression
  • BROWSE_EXTENSIONS_DIR set to valid unpacked extension → extension loads, pages render correctly
  • BROWSE_EXTENSIONS_DIR set to invalid path → Chromium launches normally (extensions silently ignored)
  • Handoff (headless → headed) still works with extensions loaded

🤖 Generated with Claude Code

When the BROWSE_EXTENSIONS_DIR environment variable is set to a path
containing an unpacked Chrome extension, browse launches Chromium in
headed mode with the window off-screen (simulating headless) and loads
the extension.

This enables use cases like ad blockers (reducing token waste from
ad-heavy pages), accessibility tools, and custom request header
management — all while maintaining the same CLI interface.

Implementation:
- Read BROWSE_EXTENSIONS_DIR env var in launch()
- When set: switch to headed mode with --window-position=-9999,-9999
  (extensions require headed Chromium)
- Pass --load-extension and --disable-extensions-except to Chromium
- When unset: behavior is identical to before (headless, no extensions)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@yinanli1917-cloud yinanli1917-cloud force-pushed the feat/browse-extension-support branch from 3d04eec to c90cfe7 Compare March 23, 2026 01:44
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.

1 participant