How to get HTML of page with shadow DOM flattened

182 views
Skip to first unread message

DigiDan

unread,
Jun 5, 2021, 1:24:55 AM6/5/21
to chrome-debugging-protocol

What is the best way to get the HTML of a page with all shadow DOM flattened.

I can see in the Chrome Devtools Protocol that there is a DOMSnapshot.captureSnapshot that returns a DocumentSnapshot object. However I’m not sure how to go from this to the HTML.

GoogleChromeLabs has a ‘dom2html’ script that serialises a dom-like JSON tree into HTML but I can’t see how to convert the above DocumentSnapshot object into a dom-like JSON tree to use by this script.

Thanks for any help

Luc Gagan

unread,
Nov 10, 2023, 2:52:52 PM11/10/23
to chrome-debugging-protocol
Have you found the answer?

Stuck with the same question

Reply all
Reply to author
Forward
0 new messages