[Adblock] Procedural `:matches-css()`, `:matches-css-before()` And `:matches-css-after()` Are Missing Regex Support.
Adblock Procedural Filters: Understanding the Limitations of :matches-css()
, :matches-css-before()
, and :matches-css-after()
As an Adblock user, you're likely familiar with the power of procedural filters in blocking unwanted content on your favorite websites. However, have you ever encountered a situation where your carefully crafted filter doesn't work as expected? If so, you're not alone. In this article, we'll delve into the limitations of :matches-css()
, :matches-css-before()
, and :matches-css-after()
procedural filters in Adblock, specifically highlighting the missing regex support in these filters.
What are Procedural Filters?
Procedural filters are a type of filter in Adblock that allow you to write custom code to block specific elements on a webpage. They're incredibly powerful and flexible, enabling you to create complex filters that can target specific elements based on various criteria. Procedural filters use a syntax similar to CSS, making them easy to learn and use, even for those without extensive programming experience.
The Problem with Regex Support
Regex (regular expressions) support is a crucial feature in procedural filters, allowing you to use regular expressions to match patterns in CSS properties. However, as of the current version of Adblock, :matches-css()
, :matches-css-before()
, and :matches-css-after()
procedural filters do not support regex. This means that filters like the ones shown below will not work:
cgpersia.com##.menu-item > a:matches-css(background-color: /rgb\(187/)`
cgpersia.com##.post:matches-css-before(display: /blo/)
cgpersia.com##.post:matches-css-after(clear: /bot/)
These filters attempt to use regex to match specific patterns in CSS properties, but since regex support is missing, they will not be executed.
What's the Impact of Missing Regex Support?
The impact of missing regex support in :matches-css()
, :matches-css-before()
, and :matches-css-after()
procedural filters is significant. Without regex support, you'll be limited in your ability to create complex filters that target specific elements based on various criteria. This can make it more challenging to block unwanted content on your favorite websites.
Examples of Filters without Regex Support
To illustrate the limitations of missing regex support, let's take a look at some examples of filters that would work without regex support:
cgpersia.com##div:matches-css(background-color: rgb(187, 142, 68))
cgpersia.com##.post:matches-css-before(display: block)
cgpersia.com##.post:matches-css-after(clear: both)
As you can see, these filters use a syntax similar to CSS, but without the use of regex. This means that they will work as expected, even though they're not using regex.
Workarounds and Alternatives
While the missing regex support in :matches-css()
, :matches-css-before()
, and :matches-css-after()
procedural filters can be frustrating, there are some workarounds alternatives you can use:
- Use
:matches-css()
without regex: As shown in the examples above, you can use:matches-css()
without regex to create filters that target specific elements based on CSS properties. - Use
:matches-css-before()
and:matches-css-after()
without regex: Similarly, you can use:matches-css-before()
and:matches-css-after()
without regex to create filters that target specific elements based on CSS properties. - Use
element
filters: If you need to target a specific element based on its CSS properties, you can useelement
filters instead of procedural filters. - Use
css
filters: If you need to target a specific element based on its CSS properties, you can usecss
filters instead of procedural filters.
In conclusion, the missing regex support in :matches-css()
, :matches-css-before()
, and :matches-css-after()
procedural filters can be a limitation for Adblock users. However, by understanding the limitations of these filters and using workarounds and alternatives, you can still create effective filters to block unwanted content on your favorite websites. We hope this article has provided you with a better understanding of the limitations of procedural filters in Adblock and how to work around them.
We hope that the Adblock developers will consider adding regex support to :matches-css()
, :matches-css-before()
, and :matches-css-after()
procedural filters in the future. This would greatly enhance the power and flexibility of procedural filters and make it easier for users to create complex filters that target specific elements based on various criteria.
Q: What are procedural filters in Adblock?
A: Procedural filters are a type of filter in Adblock that allow you to write custom code to block specific elements on a webpage. They're incredibly powerful and flexible, enabling you to create complex filters that can target specific elements based on various criteria.
Q: What is the difference between :matches-css()
and :matches-css-before()
and :matches-css-after()
procedural filters?
A: :matches-css()
procedural filters match elements based on their CSS properties, while :matches-css-before()
and :matches-css-after()
procedural filters match elements based on their CSS properties before and after they are applied, respectively.
Q: Why is regex support missing from :matches-css()
, :matches-css-before()
, and :matches-css-after()
procedural filters?
A: The reason for the missing regex support in :matches-css()
, :matches-css-before()
, and :matches-css-after()
procedural filters is not explicitly stated by the Adblock developers. However, it's likely due to the complexity of implementing regex support in procedural filters.
Q: Can I use :matches-css()
without regex?
A: Yes, you can use :matches-css()
without regex to create filters that target specific elements based on CSS properties.
Q: Can I use :matches-css-before()
and :matches-css-after()
without regex?
A: Yes, you can use :matches-css-before()
and :matches-css-after()
without regex to create filters that target specific elements based on CSS properties.
Q: What are some workarounds and alternatives to missing regex support in :matches-css()
, :matches-css-before()
, and :matches-css-after()
procedural filters?
A: Some workarounds and alternatives to missing regex support in :matches-css()
, :matches-css-before()
, and :matches-css-after()
procedural filters include:
- Using
:matches-css()
without regex - Using
:matches-css-before()
and:matches-css-after()
without regex - Using
element
filters - Using
css
filters
Q: Will the Adblock developers add regex support to :matches-css()
, :matches-css-before()
, and :matches-css-after()
procedural filters in the future?
A: We hope that the Adblock developers will consider adding regex support to :matches-css()
, :matches-css-before()
, and :matches-css-after()
procedural filters in the future. This would greatly enhance the power and flexibility of procedural filters and make it easier for users to create complex filters that target specific elements based on various criteria.
Q: How can I get the most out of procedural filters in Adblock?
A: To get the most out of procedural filters in Adblock, we recommend:
- Using
:matches-css()
without regex - Using
:matches-css-before()
and:matches-css-after()
without regex - Using
element
filters - Using `` filters
- Experimenting with different filter syntax and combinations
Q: Where can I find more information about procedural filters in Adblock?
A: You can find more information about procedural filters in Adblock by:
- Visiting the Adblock documentation website
- Checking out the Adblock community forums
- Searching for tutorials and guides on YouTube and other online platforms
In conclusion, procedural filters in Adblock are a powerful tool for blocking unwanted content on your favorite websites. While the missing regex support in :matches-css()
, :matches-css-before()
, and :matches-css-after()
procedural filters can be a limitation, there are workarounds and alternatives that can help you get the most out of these filters. We hope this Q&A article has provided you with a better understanding of procedural filters in Adblock and how to use them effectively.