Opened 4 years ago

Last modified 2 years ago

#2360 new change

Support XPath or at least :has() pseudo-selector to hide parent by it's child — at Initial Version

Reported by: Lain_13 Assignee:
Priority: P2 Milestone:
Module: Core Keywords: meta, filtersyntax
Cc: mapx, greiner, sebastian, fhd, arthur Blocked By:
Blocking: Platform: Unknown
Ready: no Confidential: no
Tester: Unknown Verified working: no
Review URL(s):

Description

Background

Sometimes it is not possible to properly hide advertisement block because it barely has any difference from the rest of the blocks on the page. It could be a paid post with advertisement link in the blog or ads in the search results (like ads on Yandex which were impossible to hide with adblock for a while and recently became hideable simply by mistake). The general problem is the same since there is no way to target that block. It's only possible to hide something inside of it and often that is far from being enough to even get rid of the advertisement.

What to change

There are two general propositions and actually one doesn't exclude another. So, both could be implemented.

  1. Add support for XPath as it's suggested here: https://adblockplus.org/forum/viewtopic.php?f=4&t=21209

In general XPath seems like a generic solution for various problems but XPath filters will have a negative impact on the performance due to the necessity to modify a code of the page and it isn't clear how to monitor dynamic changes to apply such filter to dynamically added or modified page elements.

  1. Add support for the future CSS4 pseudo-selector :has() http://dev.w3.org/csswg/selectors-4/#relational

This solution is less generic and addresses only this particular problem of blocking parent nodes by the child nodes. Also, it doesn't allow to search by content - only by nodes themselves and their specific parameters. Yet it's based on existing CSS functionality, so it will be possible to bind observer to the document to check for new parent nodes and bind another observer object to them to check for changes within only these particular nodes in case specific child node will be added. With time in a new versions of the browsers, it will be possible to completely disable such functionality due to native support of CSS4 selectors. BTW, it's possible to look at jQuery sources for this functionality since they supported :has() pseudo-selector in their selectors way before it was even added into CSS4 drafts.

Downside: seems like both propositions will be impossible to implement on platforms which didn't support browser extensions like Android app.

Change History (0)

Note: See TracTickets for help on using tickets.