📢 Try installing a desktop browser extension and synchronize bookmarks with your XBrowser.

How to Write Exception Rules

The main function of exception rules is to correct false positives caused by regular blocking rules. For example, we wrote a general rule that can block ads in most cases, but in some cases it causes false positives on normal content. In this case, we can add an exception rule to avoid false positives on normal content.

Series Navigation

URL Blocking Exception Rules

“@@” serves as the identifier for URL blocking exception rules, followed by a regular URL blocking rule

For example, suppose we wrote the following URL blocking rule:

/path/of/ad*

At this time, resource URLs like the following will be matched:

https://www.example.com/path/of/ad/banner.js
https://www.example.com/path/of/ad-show.js
https://www.example.com/path/of/advanced/

But the last resource URL is normal content that was falsely blocked by the rule “/path/of/ad*”. In this case, we can add an exception rule to avoid false positives on normal resource URLs.

@@www.example.com/path/of/advanced/

This exception rule solves the false positive problem mentioned above. We can see that the syntax of exception rules is very simple: it starts with “@@” followed by a regular URL rule, except this URL rule is not used to match ads, but to match a normal resource that was falsely blocked.

Usually, exception rules also include specific domain constraints, such as the following rule:

@@/path/of/advanced@example.com

This exception rule only takes effect on sites with the second-level domain “example.com”.

@@/path/of/advanced$domain=example.com

Equivalent to the above exception rule, this is the ABP rule syntax.

Hidden Element Exception Rules

“@#” serves as the identifier for hidden element exception rules, followed by a regular hidden element rule

Hidden element exception rules are for global rules. For example, consider the following global hidden element rule:

##div[title*="ad"]

On the website www.example.com, the following page element will be falsely blocked:

<div title="advanced">
some content
</div>

In this case, we just need to add the following exception rule to avoid false positives:

@#div[title*="ad"]@example.com

The equivalent ABP syntax is as follows:

example.com#@#div[title*="ad"]