In this article, we will discuss the leading double-pipe symbols in AdBlock scripting syntax and how they work with domain/hostnames URLs.
Understanding Leading Double-Pipe Symbols
Leading double-pipe symbols (||) are used in AdBlock scripting syntax to match the beginning of a domain or hostname URL. This is particularly useful when you want to block ads from specific websites or domains.
Disabling Reddit Auto-Translation
For instance, if you want to disable Reddit's auto-translation feature, you can use the following AdBlock filter:
||redditmedia.com^$script, domain=redditmedia.com
||redditstatic.com^$script, domain=redditstatic.com
||reddit.com^$script, domain=reddit.com
||reddit.com^$third-party, domain=reddit.com
||reddit.com^$domain=reddit.com#@#reddit.com/r/[^/]*/about/[^/]*/translate
In this filter, the leading double-pipe symbols (||) are used to match the beginning of the domain names redditmedia.com, redditstatic.com, and reddit.com. The ^ symbol at the end of each URL indicates that the match should be at the start of the URL.
The $script keyword is used to block scripts, which are often used for ads. The domain=reddit.com rule ensures that the filter applies only to the reddit.com domain.
The #@# syntax is used to create a custom rule that matches specific patterns within the domain. In this case, it matches Reddit subreddits with an about and a translate subdirectory, which are used for Reddit's auto-translation feature.
Other Uses of Leading Double-Pipe Symbols
Leading double-pipe symbols can also be used with wildcards to match a range of URLs. For example, ||*.example.com would match any URL that starts with *.example.com.
Summary
In summary, leading double-pipe symbols are a powerful tool in AdBlock scripting syntax for matching the beginning of domain or hostname URLs. They can be used in conjunction with other keywords and rules to block ads or customize your browsing experience.