Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More

chrome-remote-interface

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chrome-remote-interface

Chrome Debugging Protocol interface


Version published
Weekly downloads
315K
decreased by-43.4%
Maintainers
1
Weekly downloads
 
Created

What is chrome-remote-interface?

The chrome-remote-interface npm package is a tool that allows you to interact with the Chrome DevTools Protocol. This enables you to control, inspect, and debug web pages and web applications programmatically.

What are chrome-remote-interface's main functionalities?

Remote Debugging

This feature allows you to remotely debug a web page. The code sample demonstrates how to navigate to a URL, wait for the page to load, capture a screenshot, and save it to a file.

const CDP = require('chrome-remote-interface');

CDP(async (client) => {
    const {Network, Page} = client;

    await Network.enable();
    await Page.enable();

    Page.navigate({url: 'https://example.com'});
    Page.loadEventFired(async () => {
        const result = await Page.captureScreenshot();
        require('fs').writeFileSync('screenshot.png', result.data, 'base64');
        client.close();
    });
}).on('error', (err) => {
    console.error(err);
});

Network Monitoring

This feature allows you to monitor network requests and responses. The code sample demonstrates how to log URLs of requests and responses.

const CDP = require('chrome-remote-interface');

CDP(async (client) => {
    const {Network} = client;

    await Network.enable();

    Network.requestWillBeSent((params) => {
        console.log('Request:', params.request.url);
    });

    Network.responseReceived((params) => {
        console.log('Response:', params.response.url);
    });
}).on('error', (err) => {
    console.error(err);
});

JavaScript Execution

This feature allows you to execute JavaScript in the context of the web page. The code sample demonstrates how to evaluate a JavaScript expression to get the document title.

const CDP = require('chrome-remote-interface');

CDP(async (client) => {
    const {Runtime} = client;

    await Runtime.enable();

    const result = await Runtime.evaluate({expression: 'document.title'});
    console.log('Title:', result.result.value);

    client.close();
}).on('error', (err) => {
    console.error(err);
});

Other packages similar to chrome-remote-interface

FAQs

Package last updated on 04 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts