XBrowser’s rule is not completely compatible with ABP rule writing. You know,ABP was born in PC era, so we did not fully implement the Ad blocking rules of ABP because of the performance of mobile devices, but provided simple and efficient Ad blocking strategy and rule writing, basically taking into account both performance and blocking effect.
After testing, XBrowser can execute more than 10,000 records Ad-blocking rules while browsing the page without significant impact on page rendering.
Most of the ABP rules can be imported into XBrowser by providing automatic rule importing tools in XBrowser. However, it is not recommended to import ABP official complete rules directly, because most of the ABP official rules are for PC browsers. Loading too many rules will only lead to unnecessary performance consumption.
Like ABP, XBrowser provide two different kinds of ad-blocking strategy.“Interception strategy” and “Element hiding strategy”You can choose appropriate blocking strategy for different types of ads.
The interception strategy blocks AD by matching the URL of the advertising website before the network request, which can effectively be blocking advertising resources loaded from outside, and the performance is also the best.
“Interception strategy” provides two matching methods, one is based on domain name and directory matching and the other is based on Regular expression matching. From the performance point of view, you should first use domain name and directory matching to write rules. Regular expression matching is complementary.
Like the rule syntax of ABP, the control parameter is immediately followed by “$”.The currently supported parameter option is “3p” which corresponds to the “third party” of ABP. The following example shows its usage.
Block url whose path start with ‘/ad/banner’ . But this rule is only valid for resources url of the third party. In other words, resources under the current domain name are not limited.
For users who know regular expressions, they can achieve more flexible pattern matching through regular expressions.
Convention: regular expression rules start with “–”.In other words, “–” is followed by the regular expression you want to write, as shown in the example below.
For some ads that are not loaded by external resources and scripts. In other words, we can’t block it by interception strategy.
At this point, you can remove advertising elements from the page by “Element hiding” rule.
The element hiding rule same as ABP Element hiding rule which starts with “##” and followed by a CSS selector expression. Here are some examples of hidden element rules.
Like the hidden element rule of ABP, the scope of the Hiding element rule can be controlled by adding a domain name prefix, as shown in the following example.
By default, the blocking rules you write will take effect on all sites except whitelists. Sometimes we can limit the scope of the rules in order to avoid mistakenly killing other sites. these rules will only take effect under certain domain names.
To set the scope of a rule, simply add “@” after the original rules and followed by the domain name we need to qualify. Below are valid rules with a scope.
email@example.com firstname.lastname@example.org ###email@example.com
In order to be compatible with the writing of ABP’s element hiding rule scopes, the following two methods are equivalent.
The scope supports multiple domain names, and the domain names are separated by “,”. The following is a example.
In addition, we have provided an ad-blocking test case page, which you can use to test whether your ad-blocking strategy works properly.