ContentBlocker icon indicating copy to clipboard operation
ContentBlocker copied to clipboard

Recent versions of Chromium support :has() CSS selector, AG Content Blocker should support it

Open superlex opened this issue 2 years ago • 2 comments

Prerequisites

Please answer the following questions for yourself before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

  • [x] I am running the latest version
  • [x] I checked the documentation and found no answer
  • [x] I checked to make sure that this issue has not already been filed

Problem Description

Recent versions of Chromium support :has() CSS selector, AG Content Blocker supports it as well. Btw, AG Content Blocker recognizes only this syntax: example.org##body > div > p:has(>a) and it works like a charm. However, it should recognize this syntax too: example.org#?#body > div > p:-abp-has(>a) example.org#?#body > div > p:has(>a)

Proposed Solution

  1. Change AG Content Blocker behavior in order to recognize the correct syntax;
  2. Update android-content-blocker/filters/*.txt lists adding AG filters that use :has() css selector .

Alternatives Considered

Update android-content-blocker/filters/*.txt lists adding AG filters that use :has() css selector, using syntax recognized by Samsung Internet.

Additional Information

Android 13 - One UI 5 Samsung Internet 22.0.6.9 AG Content Blocker 2.7.2

superlex avatar Oct 03 '23 23:10 superlex

Some additional thoughts. As more and more browsers support :has() native pseudo-class, maybe best solution is to add all rules having :has() to android-content-blocker/filters/*.txt lists with the syntax ##, like explained in the wiki:

Rules with the :has() pseudo-class should use native implementation of :has() if they use ## marker and if it is possible, i.e. with no other extended selectors inside.

In this way no additional code would be necessary for ContentBlocker, furthermore other browser having a (basic) built-in adblock can take advantage of android-content-blocker/filters/*.txt lists, for example Vivaldi. This is not a priority for AG, of course, but it could prove beneficial in the future.

References https://github.com/AdguardTeam/ExtendedCss#extended-css-has https://developer.mozilla.org/en-US/docs/Web/CSS/:has https://caniuse.com/css-has

superlex avatar Oct 28 '23 10:10 superlex

Hoang van canh

223047 avatar Nov 15 '23 04:11 223047