uBlock Origin is a popular ad-blocking extension for web browsers that allows users to customize their browsing experience. One of the powerful features of uBlock Origin is the ability to create network filters, which can be used to block specific elements or content on websites. In this article, we will explore the use of wildcards in uBlock Origin network filters, specifically in the path of URLs.
Before we dive into wildcards, let's first understand the basics of network filters. Network filters in uBlock Origin are rules that determine what content should be blocked or allowed on a webpage. These filters are written using a simple syntax and can target specific URLs, domains, or even specific elements on a webpage.
What are wildcards?
Wildcards are special characters that can be used in network filters to match multiple characters or patterns. In uBlock Origin, the asterisk (*) is used as a wildcard character. When used in a network filter, the asterisk matches any number of characters in the specified position.
For example, let's say you want to block all URLs that have the word "ads" in them. You can use the following network filter:
example.com/*ads*
This filter will match any URL on the example.com domain that contains the word "ads" anywhere in its path.
Using wildcards in the path
When using wildcards in the path of a URL, it's important to understand how they behave. Let's take a look at a few examples to illustrate their usage:
Example 1:
If you want to block all URLs that start with "https://example.com/ads/", you can use the following network filter:
||example.com/ads/*
The asterisk (*) after "/ads/" will match any number of characters that come after it in the URL path.
Example 2:
If you want to block all URLs that end with "/images", you can use the following network filter:
||example.com/*/images
The asterisk (*) before "/images" will match any number of characters that come before it in the URL path.
Example 3:
If you want to block all URLs that contain the word "blog" anywhere in the path, you can use the following network filter:
||example.com/*blog*
The asterisks (*) before and after "blog" will match any number of characters that come before or after it in the URL path.
These are just a few examples of how wildcards can be used in the path of a URL. By combining wildcards with other network filter syntax, you can create powerful rules to block or allow specific content on websites.
Conclusion
Wildcards in uBlock Origin network filters provide a flexible way to target specific URLs or patterns in the path of a URL. By using the asterisk (*) as a wildcard character, you can match any number of characters in the specified position. This allows you to create precise rules to block or allow content on websites, enhancing your browsing experience.
References
| Reference | Link |
|---|---|
| uBlock Origin Documentation | https://github.com/gorhill/uBlock/wiki |
| uBlock Origin Support | https://github.com/gorhill/uBlock/wiki/Support |