Reputation: 423
As I mentioned in this question, I noticed Dashlane's Google Chrome extension modifying the styles on my web app when using their auto-fill functionality.
Setting the CSS properties of interest as !important
prevented the injected styles from being effectively displayed. But I was wandering if there is a way to prevent these extensions from injecting styles on existing elements on the page in the first place.
I think is important to point out the word 'existing' because some of these extensions might have to add and manipulate their own elements in order to work properly. But I don't want them interfering with anything that I've created.
Upvotes: 3
Views: 465
Reputation: 1
You can mitigate style injection by third-party extensions using Shadow DOM to encapsulate your web components. Shadow DOM creates a scoped boundary for styles, preventing external CSS from affecting your app's elements. While not foolproof, it adds a layer of protection against unwanted style modifications.
Upvotes: 0