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

cdp-tunnel

v1.0.9

Published

Chrome Extension CDP Proxy - 通过 Chrome 扩展将 chrome.debugger API 暴露为 WebSocket 端点

Downloads

959

Readme

CDP Tunnel


Architecture

┌─────────────────────────────────────────────────────────────────┐
│                        Proxy Server                             │
│                     (localhost:9221)                            │
│                                                                 │
│   /plugin  ←─── Chrome Extension (WebSocket)                    │
│   HTTP     ←─── Playwright/Puppeteer Clients                    │
└─────────────────────────────────────────────────────────────────┘
         ↑              ↑              ↑
         │              │              │
    Client 1       Client 2       Client 3
   (clientId_1)    (clientId_2)    (clientId_3)

Features

  • Multi-client Support - Multiple Playwright/Puppeteer clients can connect simultaneously
  • Message Isolation - Pages created by each client are owned by that client
  • Configuration Page - Visualize connection status, client list, and controlled pages
  • Auto Reconnect - Extension automatically reconnects to the server

Screenshot

Config Page

Quick Start

Option 1: Install via npm (Recommended)

# Install globally
npm install -g cdp-tunnel

# Start server
cdp-tunnel start

# Check status
cdp-tunnel status

# Install Chrome extension (opens interactive guide)
cdp-tunnel extension

Option 2: Download from GitHub Releases

  1. Go to GitHub Releases
  2. Download cdp-tunnel-extension.zip from the latest release
  3. Unzip the file
  4. Open chrome://extensions/ in Chrome
  5. Enable "Developer mode"
  6. Click "Load unpacked"
  7. Select the unzipped extension directory

Option 3: Manual Installation

1. Start the Proxy Server

cd server
npm install
node proxy-server.js

The server will start on localhost:9221.

2. Install Chrome Extension

  1. Open chrome://extensions/
  2. Enable "Developer mode"
  3. Click "Load unpacked"
  4. Select the extension-new directory

3. Connect the Extension

Click the extension icon, enter the server address in the configuration page, and click "Save and Connect".

3. Client Connection

// Playwright
const { chromium } = require('playwright');

const browser = await chromium.connectOverCDP('http://localhost:9221');
const context = browser.contexts()[0];
const page = await context.newPage();
await page.goto('https://example.com');

// Puppeteer
const puppeteer = require('puppeteer');

const browser = await puppeteer.connect({
  browserWSEndpoint: 'ws://localhost:9221'
});
const page = await browser.newPage();
await page.goto('https://example.com');

4. Using with agent-browser

agent-browser is a browser automation CLI that can connect to CDP Tunnel:

# Install agent-browser
npm install -g agent-browser

# Connect to CDP Tunnel
agent-browser --cdp http://localhost:9221 open https://example.com

# Take a snapshot
agent-browser --cdp http://localhost:9221 snapshot -i

# Interact with elements
agent-browser --cdp http://localhost:9221 click @e1
agent-browser --cdp http://localhost:9221 fill @e2 "hello"

# Take screenshot
agent-browser --cdp http://localhost:9221 screenshot output.png

This allows you to control the browser through CDP Tunnel using simple CLI commands.

Multi-client Usage

All clients connect to the same endpoint http://localhost:9221. The server automatically assigns a unique clientId to each connection.

// Multiple clients can connect simultaneously
const browser1 = await chromium.connectOverCDP('http://localhost:9221');
const browser2 = await chromium.connectOverCDP('http://localhost:9221');
const browser3 = await chromium.connectOverCDP('http://localhost:9221');

// Pages created by each client are independent
const page1 = await browser1.contexts()[0].newPage();
const page2 = await browser2.contexts()[0].newPage();
const page3 = await browser3.contexts()[0].newPage();

Configuration Page

Click the extension icon to open the configuration page, where you can view:

  • CDP Client List - Shows connected Playwright/Puppeteer clients
  • Controlled Pages List - Shows controlled pages with click-to-navigate support
  • Activity Log - Connection status change records

Project Structure

cdp-tunnel/
├── server/
│   └── proxy-server.js      # Proxy server
├── extension-new/
│   ├── background.js        # Extension Service Worker
│   ├── config-page-preview.html  # Configuration page
│   ├── config-page.js       # Configuration page script
│   ├── core/
│   │   ├── state.js         # State management
│   │   └── websocket.js     # WebSocket connection management
│   └── features/
│       ├── cdp-router.js    # CDP message routing
│       └── screencast.js    # Screenshot functionality
└── tests/
    ├── playwright-single.js      # Single client test
    ├── playwright-multi.js       # Multi-client test
    └── playwright-interactive.js # Interactive test

Testing

# Single client test
node tests/playwright-single.js

# Multi-client test
node tests/playwright-multi.js

# Interactive test
node tests/playwright-interactive.js

Notes

  1. Port Availability - Ensure port 9221 is not in use
  2. Extension Permissions - The extension requires debugger, tabs, and other permissions
  3. Browser Limitation - Only one extension can control a browser via debugger at a time

License

This project is licensed under the Apache License 2.0 with Attribution Requirement.

See LICENSE for details.


If you use this project in your work, please include attribution:

  • Project: CDP Tunnel
  • Author: dyyz1993
  • Source: https://github.com/dyyz1993/cdp-tunnel