Created
February 22, 2019 16:26
-
-
Save jsoverson/3086b3dc6345f1cadd140d94425807e3 to your computer and use it in GitHub Desktop.
Puppeteer base with CDP sessions on every tab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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