Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support cosmetic filtering !important display overrides in "Standard" blocking mode #22474

Open
antonok-edm opened this issue Apr 21, 2022 · 1 comment
Assignees
Labels
bug feature/shields/adblock Blocking ads & trackers with Shields feature/shields The overall Shields feature in Brave. features/shields/cosmetic-filtering OS/Android Fixes related to Android browser functionality OS/Desktop

Comments

@antonok-edm
Copy link
Collaborator

#22264 added support for most types of cosmetic filtering to override !important in-page style properties. It is still not yet supported in Standard shields mode due to the use of document.adoptedStyleSheets. The addRule and removeRule APIs it provides are required to support protecting 1st-party page content, but this injection method but will fail to override an in-page style with a higher specificity if it has !important. document.adoptedStyleSheets is injected as an author-origin style at the end of the page's stylesheets.

All other cosmetic filter CSS injection uses WebDocument::InsertStyleSheet, which inserts CSS as a user-origin style. This is ideal, other than the fact that there is no equivalent to the addRule and removeRule APIs for it. There is WebDocument::RemoveInsertedStyleSheet, but building the equivalent injection system with one stylesheet per rule has prohibitive performance impact.

The ideal solution will involve exposing the addRule and removeRule methods on the C++ CSSStyleSheet class so it can be used for user-origin stylesheets, but through a new public API in Blink code (since CSSStyleSheet is not an exported member).

@antonok-edm antonok-edm added bug feature/shields The overall Shields feature in Brave. feature/shields/adblock Blocking ads & trackers with Shields OS/Android Fixes related to Android browser functionality features/shields/cosmetic-filtering OS/Desktop labels Apr 21, 2022
@antonok-edm antonok-edm self-assigned this Apr 21, 2022
@ryanbr
Copy link

ryanbr commented Nov 22, 2024

Safe to close @antonok-edm ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug feature/shields/adblock Blocking ads & trackers with Shields feature/shields The overall Shields feature in Brave. features/shields/cosmetic-filtering OS/Android Fixes related to Android browser functionality OS/Desktop
Projects
None yet
Development

No branches or pull requests

2 participants