Description
Chrome extensions are not working with agent-browser. Content scripts are not being injected into pages, even though the extension appears to load (background pages are visible in CDP).
Interestingly, using Playwright directly does work when channel: 'chromium' is specified, suggesting the issue is specific to how agent-browser configures Playwright.
Reproduction
# 1. Create a minimal test extension
mkdir -p /tmp/test-extension
cat > /tmp/test-extension/manifest.json <<'EOF'
{
"manifest_version": 3,
"name": "Test Extension",
"version": "1.0",
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content.js"],
"run_at": "document_idle"
}
]
}
EOF
cat > /tmp/test-extension/content.js <<'EOF'
console.log('[TEST EXTENSION] Injected!');
window.TEST_EXTENSION_LOADED = true;
document.body.style.border = "5px solid red";
EOF
# 2. Launch with extension
agent-browser close
agent-browser --headed --extension /tmp/test-extension open https://example.com
# 3. Check if content script ran
agent-browser eval 'window.TEST_EXTENSION_LOADED' # Returns undefined, should be true
agent-browser console # No "[TEST EXTENSION] Injected!" message
Expected Behavior
Extension content scripts should be injected and execute. When using Playwright directly with the same configuration, it works:
import { chromium } from 'playwright';
const context = await chromium.launchPersistentContext(userDataDir, {
channel: 'chromium',
args: [`--load-extension=${extPath}`, `--disable-extensions-except=${extPath}`]
});
// Result: content scripts ARE injected ✅
Workaround
Use Playwright directly instead of agent-browser. The following configuration works:
import { chromium } from 'playwright-core';
const extensionPath = '/path/to/extension';
const context = await chromium.launchPersistentContext(userDataDir, {
headless: false,
channel: 'chromium', // This is required!
args: [
`--disable-extensions-except=${extensionPath}`,
`--load-extension=${extensionPath}`
]
});
Investigation
- Fix attempted: Added
channel: 'chromium' to dist/browser.js line 1147 in the launchPersistentContext call (where hasExtensions is true)
- Result: Fix works with Playwright directly, but NOT through agent-browser
- Both Playwright and Native modes tested - neither works
- Manual Chrome launch with
--load-extension also doesn't inject content scripts on macOS Chrome 147
This suggests the issue may be deeper than just the channel parameter - possibly related to:
- How agent-browser's daemon caches code
- Chrome 147 + macOS specific behavior
- User data directory state
Environment
- agent-browser: 0.16.3
- Playwright: 1.58.2
- OS: macOS (Darwin 25.2.0, arm64)
- Chrome: 147.0.7632.160 (system Chrome)
Related
Description
Chrome extensions are not working with agent-browser. Content scripts are not being injected into pages, even though the extension appears to load (background pages are visible in CDP).
Interestingly, using Playwright directly does work when
channel: 'chromium'is specified, suggesting the issue is specific to how agent-browser configures Playwright.Reproduction
Expected Behavior
Extension content scripts should be injected and execute. When using Playwright directly with the same configuration, it works:
Workaround
Use Playwright directly instead of agent-browser. The following configuration works:
Investigation
channel: 'chromium'todist/browser.jsline 1147 in thelaunchPersistentContextcall (wherehasExtensionsis true)--load-extensionalso doesn't inject content scripts on macOS Chrome 147This suggests the issue may be deeper than just the
channelparameter - possibly related to:Environment
Related
channel: 'chromium'for extension support