painty / CSS-Used-ChromeExt

Get all css rules used by the selected DOM and its children.
https://chrome.google.com/webstore/detail/css-used/cdopjfddjlonogibjahpnmjpoangjfff
MIT License
263 stars 62 forks source link

npm module #8

Closed emmastone9 closed 6 years ago

emmastone9 commented 6 years ago

Hi, Suggestion: Is it possible to build NPM module or an API wrapper that can query a given node for a URL and output the local preview to HTML file?

I am happy to contribute back as a PR, will need some hand holding though..

painty commented 6 years ago

I can't think of such a usage scenario. Could you explain why you need it to work in a NPM way?

emmastone9 commented 6 years ago

I am trying to get the extension working in chrome headless mode and thereby an API will be useful.

painty commented 6 years ago

So let me guess. You want to " tree-shaking" CSS ?

It's not safe to use this extension to do such thing currently. Because the result is generated based on the CURRENT HTML DOM.

If a div doesn't exist in the document unless a specific user interaction, the result may miss out the style rules for the newly born div.

In another words, the result is only responsible for the moment you inspect the target element.

Maybe there can be a "start monitor" and "stop monitor" , and the result can reflect the period but not the snapshot.

emmastone9 commented 6 years ago

@painty you are correct, the above will only get a snapshot at time t. 95% of the pages that we are using the extension are static and thereby need the result based off current html dom.

Is it possible to get current HTML DOM / CSS Used via an API call or something that can be done via CLI?