{"repo":"gildas-lormeau/simple-cdp","free":true,"listed":false,"github":"https://github.com/gildas-lormeau/simple-cdp","clone":"git clone https://github.com/gildas-lormeau/simple-cdp.git","description":"Lightweight JavaScript library to interact with Chromium-based browsers via the Chrome DevTools Protocol","language":"JavaScript","stars":28,"topics":["chrome-devtools-protocol","cdp","bun","deno","browser-automation"],"license":"MIT","category":"scrapers-browser-automation","readme_excerpt":"Introduction simple-cdp is a JavaScript library to interact with the Chrome DevTools Protocol. The implementation uses Proxy objects to expose APIs. This makes it very light (around 400 lines of code) and independent of protocol evolutions. Install You can install the library: - from JSR: - from NPM: Start the browser Start a Chromium-based browser with the switches --remote-debugging-port and --user-data-dir . Since Chrome 136, --remote-debugging-port is ignored when the browser runs on the default profile, so --user-data-dir must point to another directory. Without it, the browser starts but nothing listens on the port. Usage example Run the script below. Driving several targets The cdp instance is connected to the browser itself. Attach to a target to get a session ID, and pass it as the last argument of the methods to address that target. One connection then drives as many targets as needed. Waiting for an event The methods resolve when the browser answers the command, which is not the same as the browser finishing the work. Wait for the matching event instead, with the once option of the listener. The listeners accept the options of EventTarget, so signal can be used to remove them. Attaching to targets automatically When targets are created by the page rather than by the script, for example when it opens a window, their IDs are unknown. Auto-attach reports a session for each target as it appears. Set waitForDebuggerOnStart to true to pause each target until Runtime.runI","default_branch":null,"files":null,"tree":[],"storefront":"/r/gildas-lormeau","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/gildas-lormeau/simple-cdp/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}