Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
  • A adblockpluscore
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 86
    • Issues 86
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Jira
    • Jira
  • Merge requests 11
    • Merge requests 11
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • eyeo
  • adblockplus
  • abc
  • adblockpluscore
  • Issues
  • #369
Closed
Open
Created Sep 20, 2021 by peace2000@peace2000

Inversing element hiding emulation using `:not()`

Background

I noticed that ABP cannot inverse :-abp-has and :-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:

image

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:

reska.fi#?#[class|="ml-adverts"]:not(:-abp-has(a[href="https://reska.fi/lounasreska/"]))

I think that combining :not with :-abp-has or :-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.

Testing Notes

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.

Release Notes

When this is in a released version of ABP, the filter documentation should be updated by merging eyeo/websites/help.eyeo.com!123

Edited Jan 06, 2022 by Justin Wernick
Assignee
Assign to
Time tracking