by mrieck · 7y ago · 0 comments
https://chrome.google.com/webstore/detail/snipcss/hbdnoadcma...
The current version is a Chrome Extension that extracts every CSS rule needed to rebuild the DOM subtree of a selected element. Unlike other tools it never uses computed styles and uses the actual DevTools protocol to get the CSS. The current extension doesn't handle CSS specificity or inheritance correctly, so I'm waiting until I fix those things before promoting it. Actually this comment is the first time I've told anyone about it.
You might want to lock this down.
Also: take my money, please.
The homepage doesn't have a link to the pricing page so I didn't think anyone would find that. I'll let you know when it's ready!
I loved the little animation with the critter coming to inspect the DOM element, but as of right now the plugin doesn't seem to actually do anything. It doesn't appear to emit any css nor is my css being transmitted to the site. It could well be that you're between iterations, but right now if I didn't know you were working on it, I'd be tempted to remove it.
I haven't had it crash in a while where it produces nothing while snipping. Maybe you found a new way to crash it. What if you try it on this site? (HackerNews as a test)
Also your Chrome version and OS might help me debug it.
The desktop version uses puppeteer so I do force a hover state on each element and get extra psuedo selectors by doing that. I'm also planning to add something so you can interact with the page first to get the page in the state you want, because right now the selection process cancels all other events (you select something by clicking).
One of the first difficult issues that I ran into was that I had to modify CSS selectors to target the subtree. For example let's say there is a selector:
#mysidebar #atable tr
Now I only want to Snip/Extract the #atable element. I have to modify the selector by chopping off #mysidebar because the html I'm giving the user is just #atable and everything below that. The problem is modifying selectors like that ruins CSS specificity. That's just one example of how things became a lot more complicated than I originally thought it would be.
Please do this. Is there a waitlist? If not, please make it so. :)
Eventually it would be cool to automatically create React/Vue templates but that's getting ahead of myself. For now I'd be happy if it just extracts the correct styles 99% of the time. Currently it's 80% there, but the last 20% is always the hardest.