Open and interact with a Chrome extension background service worker via Puppeteer CDP targets

domain: pptr.dev · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Launch Chromium with the extension loaded: const browser = await puppeteer.launch({ headless: false, args: ['--load-extension=/path/to/extension', '--disable-extensions-except=/path/to/extension'] })
  2. List all targets: const targets = await browser.targets()
  3. Find the service worker target: const swTarget = targets.find(t => t.type() === 'service_worker' && t.url().includes('chrome-extension://'))
  4. Attach a CDP session: const swClient = await swTarget.createCDPSession()
  5. Evaluate logic in the service worker: await swClient.send('Runtime.evaluate', { expression: 'self.registration.scope', returnByValue: true })
  6. Listen for messages from the extension: swClient.on('Runtime.consoleAPICalled', (event) => console.log(event.args))

Known gotchas

Related routes

enable and configure headless chrome downloads in puppeteer using cdp page.setdownloadbehavior
pptr.dev · 5 steps · unrated
Send raw Chrome DevTools Protocol commands via a CDPSession in Puppeteer
pptr.dev · 6 steps · unrated
Create isolated Puppeteer browser contexts with browser.createBrowserContext() for parallel sessions
pptr.dev · 5 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans