npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

puppeteer-chrome-debugger-transport

v1.0.0

Published

Use puppeteer-core in browser extensions via chrome.debugger API

Readme

puppeteer-chrome-debugger-transport

Use puppeteer-core in your browser extension's background page or service worker. This package provides a transport layer that uses Chrome's chrome.debugger extension API to communicate with the Chrome DevTools Protocol.

Features

  • ✨ Use Puppeteer in browser extensions
  • 🔌 Built on Chrome's native debugger API
  • 🚀 Works in both Manifest V2 and V3 extensions
  • 📦 Lightweight with minimal dependencies
  • 🎯 Full TypeScript support

Installation

npm install puppeteer-chrome-debugger-transport puppeteer-core

Prerequisites

Your extension must have the debugger permission in manifest.json:

Manifest V2

{
  "permissions": [
    "debugger",
    "tabs"
  ]
}

Manifest V3

{
  "permissions": [
    "debugger",
    "tabs"
  ]
}

Usage

Basic Example

import puppeteer from 'puppeteer-core/lib/cjs/puppeteer/web'
import { ExtensionDebuggerTransport } from 'puppeteer-chrome-debugger-transport'

async function run(tabId) {
    // Create transport connected to the tab
    const extensionTransport = await ExtensionDebuggerTransport.create(tabId)
    
    // Connect puppeteer using the transport
    const browser = await puppeteer.connect({
        transport: extensionTransport,
        defaultViewport: null,
    })

    // Use first page from pages instead of using browser.newPage()
    const [page] = await browser.pages()

    await page.goto('https://wikipedia.org')

    // Take a screenshot
    const screenshot = await page.screenshot({
        encoding: 'base64',
    });
    console.log(`data:image/png;base64,${screenshot}`)

    // Interact with the page
    const englishButton = await page.waitForSelector('#js-link-box-en > strong')
    await englishButton.click()

    const searchBox = await page.waitForSelector('#searchInput');
    await searchBox.type('telephone')
    await page.keyboard.press('Enter')

    // Clean up
    await page.close();
}

// Create a new tab and run automation
chrome.tabs.create(
    {
        active: true,
        url: 'https://www.google.co.in',
    },
    tab => (tab.id ? run(tab.id) : null)
)

Using with Existing Tab

You can also attach to an existing tab:

// Get the active tab
chrome.tabs.query({ active: true, currentWindow: true }, async (tabs) => {
    if (tabs[0]?.id) {
        await run(tabs[0].id);
    }
});

Error Handling

async function runWithErrorHandling(tabId) {
    try {
        const extensionTransport = await ExtensionDebuggerTransport.create(tabId)
        
        const browser = await puppeteer.connect({
            transport: extensionTransport,
            defaultViewport: null,
        })

        const [page] = await browser.pages()
        await page.goto('https://example.com')
        
        // Your automation code here
        
    } catch (error) {
        console.error('Automation failed:', error)
    }
}

API

ExtensionDebuggerTransport

static async create(tabId: number): Promise<ExtensionDebuggerTransport>

Creates and initializes a new transport instance connected to the specified tab.

Parameters:

  • tabId (number): The Chrome tab ID to attach the debugger to

Returns: Promise that resolves to an initialized ExtensionDebuggerTransport instance

Throws: Error if the debugger fails to attach

send(message: string): void

Sends a Chrome DevTools Protocol command. This is called internally by Puppeteer.

close(): void

Closes the debugger connection and cleans up resources.

Important Notes

Don't Use browser.newPage()

When using this transport, you should not call browser.newPage(). Instead, use the existing page:

// ✅ Correct
const [page] = await browser.pages()

// ❌ Incorrect
const page = await browser.newPage()

Tab Management

The debugger attaches to a specific tab. If the tab is closed, the connection will be terminated.

Permissions

Make sure your extension has the debugger permission, otherwise the connection will fail.

Chrome Extensions Only

This package only works in Chrome/Chromium-based browser extensions that support the chrome.debugger API.

Limitations

  • Only works in Chrome/Chromium-based browsers
  • Requires the debugger permission
  • Cannot create new tabs via browser.newPage() (must use existing tabs)
  • When debugger is attached, a notification appears in the browser

Examples

Check out the examples directory for more use cases:

  • Basic automation
  • Screenshot capture
  • Form filling
  • Web scraping in extensions

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Related Projects

Support

If you encounter any issues or have questions, please open an issue on GitHub.