Skip to content

Instantly share code, notes, and snippets.

@mohummedalee
Created January 4, 2019 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mohummedalee/4416c75b994142af1624bc15ca9668be to your computer and use it in GitHub Desktop.
Save mohummedalee/4416c75b994142af1624bc15ca9668be to your computer and use it in GitHub Desktop.
Pulling out the web-socket URL of a Chrome Debugging Protocol run – can be used to connect other services (e.g. Puppeteer) to CDP
const request = require('request');
// Assuming CDP is running on localhost
Browser.prototype.setupWSURL = async function() {
let that = this;
let url = `http://localhost:${this.port}/json/version`;
request(url,
function(err, resp, body) {
if (!err) {
that.webSocketDebuggerUrl = JSON.parse(body).webSocketDebuggerUrl;
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment