brave-browser icon indicating copy to clipboard operation
brave-browser copied to clipboard

Support procedural cosmetic filtering

Open antonok-edm opened this issue 3 years ago • 4 comments

Procedural cosmetic filtering is useful for the most evasive kinds of in-content sponsored/promoted material. It'd be great to implement this and tie it to aggressive shields settings, to handle the last few examples of cosmetic items slipping through on Reddit, YouTube, Facebook, etc.

See also:

  • Reddit promoted content on mobile https://github.com/brave/brave-browser/issues/16789
  • Facebook sponsored items https://github.com/brave/brave-browser/issues/15869
  • YouTube empty video slots https://github.com/brave/brave-browser/issues/11955
  • Washington Post anti-adblock https://github.com/brave/brave-browser/issues/21212

antonok-edm avatar Jul 13 '21 22:07 antonok-edm

Another use/test case: sponsored posts on stuff.co.nz

image

Should be handled by stuff.co.nz##[itemprop]:has(.sponsored-flag)

antonok-edm avatar Apr 12 '22 17:04 antonok-edm

How many filters makes use of other procedural selector? (e.g. :has-text) I'd imagine Chrome's upcoming support for :has is going to make this slightly less necessary.

intrnl avatar Apr 12 '22 20:04 intrnl

How many filters makes use of other procedural selector? (e.g. :has-text)

I did a survey of procedural filter operator counts in Brave's default lists a few days ago:

:has
    164
:has-text
    336
:matches-css
    15
:matches-css-before
    19
:matches-css-after
    2
:matches-path
    12
:not
    165
:upward
    239
:xpath
    49

It's not an exact metric since some filters can contain multiple chained operators, and :not is a special case since it's also a valid CSS pseudo-class, but this list still gives a good idea of how important each is. has-text in particular would be great to support.

I'd imagine Chrome's upcoming support for :has is going to make this slightly less necessary.

The recent efforts on :has are commendable, but it actually has a really long history and who knows what else may delay the implementation. Plus, support procedural cosmetic filters in general should make :has fairly simple anyways.

edit: 172 occurrences of has-text, or roughly half, are actually from HTML filters (with a ##^ separator in the rule). That uses a totally separate system from procedural filtering, even though the rules look similar. I haven't seen any other procedural filters used for HTML filtering.

edit again: :has is actually implemented now! So just the other procedural filters are left now.

antonok-edm avatar Apr 12 '22 21:04 antonok-edm

Hi Braver, Is there any update on this open ticket. I happy to contribute.

dharnil avatar Mar 06 '24 09:03 dharnil