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 30,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.
Blocking AD host whose domain is "www.example.com"
Blocking all request whose directory part of url start with '/content/ads'
Blocking request whose script's path is '/runtime/js/index960.js'
Remove page elements whose ID is "ad-container"
Remove page elements whose class name is "ad-container"
Remove all elements which property value contain the string "adv".
More instructions and examples
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.
Blocking by domain and directory
This rule will block all ad resource URL with the top-level domain name example.com, such as www.example.com, abc.example.com, etc, will be blocked.
Block any ad resource url whose path start with "/content/ads".exp:http://www.example.com/content/ads/ad.js"，"http://ad.example.com/content/ads/player/third/ad.js" etc
Blocking all ad resource url whose top domain is example.com and path start with "/content/ads"
Blocking ad resource url whose domain or directory can match with above rule
Blocking by regular expression
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.
Blocking any URL that contains the string "ads"
Blocking any URL whose suffix is ".swf"
Blocking all URL whose subdomain is "ad" + digital. for example ad.example.com,ad1.example.com, ad10.example.com
Blocking all java script whose name contains the string "ad". For example："http://www.example.com/content/sina_ad_wap.js"
Element hiding strategy
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.
Remove the page element whose id is "mybanner"
Remove the page elements whose class name is "ad-container"
Remove all elements which property value contain the string "adv"
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.
Removes an element whose id is "mybanner" and the rule takes effect only under the example.com
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.