Skip to content

Instantly share code, notes, and snippets.



Last active Dec 6, 2019
What would you like to do?
Puppeteer Shadow Dom > Dom
const puppeteer = require('puppeteer');
const url = process.env.URL || '';
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(url);
await page.evaluate(() => {
// loop through elements and copy shadow to inner
for (let element of document.getElementsByTagName('*')) {
if (element.shadowRoot) element.innerHTML = element.shadowRoot.innerHTML;
let bodyHTML = await page.content();
await browser.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment