Is there a way to detect style changes made only in the developer-tools (inspect element)?
I want to allow to save them if the user is logged in as admin.
You can access the styles of a HTMLElement using element.style
in JavaScript. So you could probably save the styles on page load, check them again when the user initiates a save and compare -- the difference would be the users changes.
As for detecting them as soon as they happen, you can use MutationObserver
to get notified of attribute changes on the page. This works for when you add styles to a specific element in the Devtools, but not for editing existing styles and (I think) adding styles to existing selectors. I'm not sure if there is a way to get an event when these change.
Edit: actually, it seems as if checking element.style
has the same limits as using MutationObserver
: only styles added for the specific element (that is, styles that show up as inline styles in the DOM) show up. There might be a way to actually access all styles, but I'm not aware of it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With