Skip to content

Instantly share code, notes, and snippets.

@jsoverson
Created February 22, 2019 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jsoverson/3086b3dc6345f1cadd140d94425807e3 to your computer and use it in GitHub Desktop.
Save jsoverson/3086b3dc6345f1cadd140d94425807e3 to your computer and use it in GitHub Desktop.
Puppeteer base with CDP sessions on every tab
const puppeteer = require('puppeteer');
async function initializeCDP(page) {
const client = await page.target().createCDPSession();
}
(async function main(){
const browser = await puppeteer.launch({
headless:false,
defaultViewport:null,
devtools: true,
});
const page = (await browser.pages())[0];
await initializeCDP(page);
browser.on('targetcreated', async (target) => {
const page = await target.page();
await initializeCDP(page);
})
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment