https://github.com/tscpp/cdp-web
Provides a lightweight way to communicate with the Chrome DevTools Protocol (CDP).
https://github.com/tscpp/cdp-web
cdp chrome chrome-devtools-protocol devtools
Last synced: 9 months ago
JSON representation
Provides a lightweight way to communicate with the Chrome DevTools Protocol (CDP).
- Host: GitHub
- URL: https://github.com/tscpp/cdp-web
- Owner: tscpp
- License: unlicense
- Created: 2023-11-12T15:21:06.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-12T15:26:28.000Z (about 2 years ago)
- Last Synced: 2025-03-06T15:40:57.920Z (10 months ago)
- Topics: cdp, chrome, chrome-devtools-protocol, devtools
- Language: TypeScript
- Homepage:
- Size: 28.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cdp-web
This library provides a lightweight way to communicate with the [Chrome DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/) (CDP). Supports browsers, Deno, Node, and Bun. Less than 2KB minified.
```javascript
import { createCdpConnection } from "cdp-web";
const cdp = await createCdpConnection({
url: "http://localhost:9222", // optional, default value
target: "page", // optional, default value
});
// Send 'Tracing.getCategories' command and wait for the result.
const categories = await cdp.send("Tracing.getCategories");
// Listen for all CDP events.
cdp.addEventListener("message", (event) => {
if (event.method === "Tracing.dataCollected") {
// Handle 'Tracing.dataCollected' event.
console.log(event.params);
}
});
```