@u4/chrome-remote-interface
TypeScript icon, indicating that this package has built-in type declarations

0.4.10 • Public • Published

chrome-CDP

[Chrome DevTools Protocol] is a generic protocol to debug / control web browser.

import { Devtools } from "@u4/chrome-remote-interface";
/**
 * Sample API usage
 *
 * The following snippet loads https://github.com and dumps every request made for 3 sec:
 */
async function test() {
  const devtools = new Devtools();
  const tab = await devtools.connectFirst("page");
  try {
    await tab.Network.enable();
    await tab.Page.enable();

    tab.Network.on("requestWillBeSent", (params) => {
      console.log("requestedUrl:", params.request.url);
    });

    const loadEventFired = tab.Page.loadEventFired();
    await tab.Page.navigate({ url: "https://github.com" });
    await loadEventFired;
    console.log("loadEventFired");
    await new Promise((r) => setTimeout(r, 3000));
  } catch (e) {
    console.error(e);
  } finally {
    tab.close();
  }
}

void test();

references

Package Sidebar

Install

npm i @u4/chrome-remote-interface

Weekly Downloads

0

Version

0.4.10

License

MIT

Unpacked Size

3.29 MB

Total Files

94

Last publish

Collaborators

  • urielch