I am trying to write a tool that runs in the browser (in Javascript) and can take a "snapshot" of the state of a website at a single point in time. It strips out script tags, inlines images and fonts to data urls, and inlines CSS. The CSS part is giving me trouble on some sites though.
I started with the assumption that document.styleSheets had an authoritative list of the current styles for a page. It seems like just picking up these rules in order does not get me all of the active styles on a page though.
Furthermore, some sheets in document.styleSheets seem to be inaccessible because of cross-origin stuff.
Is there a way to "walk the CSSOM" of a page? Ideally I would be able to do this without writing a browser extension. The end goal is an inspectable snapshot for when long-running e2e tests fail. Thanks for your help!