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 procedural cosmetic filtering #16935

Closed
antonok-edm opened this issue Jul 13, 2021 · 10 comments · Fixed by brave/brave-core#24688
Closed

Support procedural cosmetic filtering #16935

antonok-edm opened this issue Jul 13, 2021 · 10 comments · Fixed by brave/brave-core#24688

Comments

@antonok-edm
Copy link
Collaborator

antonok-edm commented Jul 13, 2021

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:

@antonok-edm
Copy link
Collaborator Author

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

image

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

@intrnl
Copy link

intrnl commented Apr 12, 2022

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.

@antonok-edm
Copy link
Collaborator Author

antonok-edm commented Apr 12, 2022

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.

@dharnil
Copy link

dharnil commented Mar 6, 2024

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

@MadhaviSeelam
Copy link

MadhaviSeelam commented Oct 18, 2024

Verification PASSED using

Brave | 1.72.83 Chromium: 130.0.6723.58 (Official Build) beta (arm64)
-- | --
Revision | b49615851cd2dc4b1c3f5f13d3207d3c032bfd8d
OS | macOS Version 14.6.1 (Build 23G93)
  1. Installed 1.72.83
  2. launched Brave
  3. opened brave://settings/shields/filters in a new tab
  4. added https://antonok.com/tmp/procedural-filter-tests/test-extended-css-rules.txt to Custom lists
  5. visited https://antonok.com/tmp/procedural-filter-tests/index.html in a new tab

Confirmed following numbered test cases are passed

  - 1,2.3
  - 6,7,8,9
  - 20,21
  - 24
  - 26
  - 28,29
step 4 step 5a step 5b
Image Image Image

@MadhaviSeelam MadhaviSeelam added OS/macOS-arm64 and removed QA/In-Progress Indicates that QA is currently in progress for that particular issue labels Oct 18, 2024
@MadhaviSeelam
Copy link

Verification PASSED using

Brave | 1.72.85 Chromium: 130.0.6723.58 (Official Build) beta (64-bit)
-- | --
Revision | 2c872aa4d2694bc73ec58e3b14538a4008a6381e
OS | Windows 11 Version 23H2 (Build 22631.4391)
  1. Installed 1.72.85
  2. launched Brave
  3. opened brave://settings/shields/filters in a new tab
  4. added https://antonok.com/tmp/procedural-filter-tests/test-extended-css-rules.txt to Custom lists
  5. visited https://antonok.com/tmp/procedural-filter-tests/index.html in a new tab

Confirmed following numbered test cases are passed

  - 1,2.3
  - 6,7,8,9
  - 20,21
  - 24
  - 26
  - 28,29
step 4 step 5a step 5b
Image Image Image

@Uni-verse Uni-verse added the QA/In-Progress Indicates that QA is currently in progress for that particular issue label Oct 31, 2024
@Uni-verse
Copy link
Contributor

Uni-verse commented Oct 31, 2024

Verified on Samsung Galaxy S21 using the following version(s):

Brave	1.72.90 Chromium: 130.0.6723.70 (Official Build) beta (64-bit) 
Revision	5f14a2225ebf4fcd654e064bde93e77fcc5d8f39
OS	Android 13; Build/TP1A.220624.014; 33; REL

Using test plan in brave/brave-core#24688 (comment)

  • Ensured the following test case numbers are passing on https://antonok.com/tmp/procedural-filter-tests/index.html after adding https://antonok.com/tmp/procedural-filter-tests/test-extended-css-rules.txt to custom filter list

    • 1, 2, 3
    • 6, 7, 8, 9
    • 20, 21, 24
    • 26, 28, 29
example example example
Image Image Image

@Uni-verse Uni-verse added QA Pass - Android ARM and removed QA/In-Progress Indicates that QA is currently in progress for that particular issue labels Nov 1, 2024
@Uni-verse
Copy link
Contributor

Verified on Samsung Galaxy Tab S7 using the following version(s):

Brave	1.72.93 Chromium: 131.0.6778.14 (Official Build) beta (64-bit) 
Revision	69e5dc20ca483a13316632df5bcd9279bb2a3cb7
OS	Android 13; Build/TP1A.220624.014; 33; REL

Using test plan in brave/brave-core#24688 (comment)

  • Ensured the following test case numbers are passing on https://antonok.com/tmp/procedural-filter-tests/index.html after adding https://antonok.com/tmp/procedural-filter-tests/test-extended-css-rules.txt to custom filter list

    • 1, 2, 3
    • 6, 7, 8, 9
    • 20, 21, 24
    • 26, 28, 29
example example example
Image Image Image

@MadhaviSeelam
Copy link

Verification PASSED using

Brave	1.72.95 Chromium: 131.0.6778.24 (Official Build) beta (64-bit) 
Revision	006619fbaf6013cb3495b90fc3885eda343087e5
OS	Linux
  1. Installed 1.72.95
  2. launched Brave
  3. opened brave://settings/shields/filters in a new tab
  4. added https://antonok.com/tmp/procedural-filter-tests/test-extended-css-rules.txt to Custom lists
  5. visited https://antonok.com/tmp/procedural-filter-tests/index.html in a new tab

Confirmed following numbered test cases are passed

  - 1,2.3
  - 6,7,8,9
  - 20,21
  - 24
  - 26
  - 28,29
step 4 step 5a step 5b
Image Image Image

@hffvld hffvld added the QA/In-Progress Indicates that QA is currently in progress for that particular issue label Nov 15, 2024
@hffvld
Copy link
Contributor

hffvld commented Nov 15, 2024

Verified on iPhone 14 and iPad Mini (6th gen) using version(s):

Device/OS: 
- iPhone 14 / iOS 17.7.1
- iPad Mini (6th gen) / iPadOS 18.0.1
Brave build: 1.73 (89)
BraveCore: 1.73.89 (131.0.6778.69)

Observed the issue #40771 which is not a blocker according to @antonok-edm

STEPS:

  1. Launch Brave
  2. Settings > Shields & Privacy
  3. Content Filtering > Add Filter By URL
  4. Add https://antonok.com/tmp/procedural-filter-tests/test-extended-css-rules.txt > Tap Update Lists
  5. Disable all filters in Default filter lists > Tap Update Lists
  6. Close the settings and navigate to https://antonok.com/tmp/procedural-filter-tests/index.html
  7. Verify

ACTUAL RESULTS:

  • Verified that the following numbered test cases are passed
    • 1, 2, 3
    • 6, 7, 8, 9
    • 20, 21
    • 24
    • 26
    • 28, 29

iPhone 14

1 2 3 4
1 2 3 4

iPad Mini (6th gen)

1 2 3 4
1 2 3 4

@hffvld hffvld added QA Pass - iPhone QA Pass - iPad and removed QA/In-Progress Indicates that QA is currently in progress for that particular issue labels Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants