Last active
December 6, 2019 15:52
-
-
Save dwsmart/15268239a08149661bf9647b02cd995d to your computer and use it in GitHub Desktop.
Puppeteer Shadow Dom > Dom
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'); | |
const url = process.env.URL || 'https://lit-element.polymer-project.org/'; | |
(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(); | |
console.log(bodyHTML); | |
await browser.close(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment