Inversing element hiding emulation using `:not()`
I noticed that ABP cannot inverse
:-abp-contains selectors. Could you consider adding support for this syntax? It's supported by uBO and AG too.
Couple of use cases:
I wanted to make a filter, that would hide a cookie banner notification on
yle.fi, if an article doesn't contain embedded tweets. That's because embedded tweets won't work unless you accept cookies. And if you hide that banner, you cannot accept them. But as only few/some articles have embedded tweets, there's no reason why the banner couldn't be hid if the article doesn't contain embedded tweets.
Article having a tweet: https://yle.fi/uutiset/3-11972567
Article not having one: https://yle.fi/uutiset/3-12107126
The rule I made for this purpose:
yle.fi#?##yle-consent-sdk-container:not(:-abp-has(~ .yle__app a[href^="https://twitter.com/"]))
Another use case:
I could use a filter
reska.fi##[class|="ml-adverts"] on https://reska.fi/ to remove some ads. But I don't want to use that rule because it will remove a widget:
That widget is a tool to find local lunch places - so it's not an ad. Annoyance, maybe but not an ad. So, in this case, a rule like this would do the trick:
I think that combining
:-abp-contains is something that, in my opinion, anyone would consider useful. :)
Opened this now, @mile-ne
What to change
- Change the element hiding emulation content script to handle
:not()around the advanced selectors.
- Add tests
- Coordinate with QA for a new testpage.
The two above use cases should work as expected. For example, when navigating to https://reska.fi/ with the custom filter
reska.fi#?#[class|="ml-adverts"]:not(:-abp-has(a[href="https://reska.fi/lounasreska/"])), adverts should be hidden but the widget highlighted in the screenshot above should not be removed.
When this is in a released version of ABP, the filter documentation should be updated by merging eyeo/websites/help.eyeo.com!123