Sawing Adblock



    Strategy


    So, Adblock ... But here I will talk not so much about ad blocking, but about optimization and proper use of this add-on, interesting for its versatility. I do not belong to those who are annoyed by the advertisement itself - the method of its delivery annoys me.More precisely, this is what annoys me :
    - heavier pages and the complexity of the process of loading them, as a result - slowing it down;
    - traffic growth (in the corporate environment);
    - spy scripts, collection of personal information;
    - when I do not see the page when the HTML document is loaded due to delays in loading some dirty tricks from the left servers;
    - the emergence of a plugin-container process that eats memory in volumes commensurate with the browser itself.
    In addition to, actually, advertising, these problems are created by no less different counters and “social widgets” (a new evil that the web 1.0 did not know about), because pages even without ads contain several counter scripts, and for every “I like” button Each social network is loaded with its own script! Therefore, my strategy will be fundamentally different from the strategy of the creators of standard subscriptions for Adblock:
    1) the main thing is not to eliminate ads, the goal is to reduce page loading time, memory consumption, traffic, etc. - optimization " from the car ", so the focus is on scripts and flash, and just hiding elements with the ## directive is the least interesting,
    2) Pareto efficiency principle: 20% of the rules block 80% of inappropriate content,
    3) (Corollary 1 and 2) universal rules, as far as possible!
    4) sites that I don’t go to / irrelevant in this Country - let them contain a bunch of inappropriate content, I categorically do not want my CPU to run through a megabyte of rules that will never work when requesting each item from a frequently visited site (or work once a year).

    Study


    The adblock (the version for firefox has been studied) is a packaged xpi (it does not unpack during installation), weighing 786 kb. Most of this archive (468 kb in compressed form, 1.3 MB in unpacked form) falls on localizations, which (unnecessary) can be easily removed from xpi using the same 7-zip. (Looking ahead: no reduction in memory consumption as a result of this procedure was found, the unpacking of the addon was also not affected).

    Blocking rules are stored in the FF profile folder, in a subfolder of adblockplus or similar by the name of the addon (other addon settings are stored in the standard browser “settings registry”). Looking there, I found 2 huge files - INI and CSS, together weighing about 1.8 MB (this "discovery" was the reason for this study). It is clear that such volumes (especially CSS!) Will not be in vain, even if our browser were written in pure assembler. In order to understand just how cumbersome the Adblock is for the system, measurements were taken of memory consumption with the latest, at the time of writing, versions of the Adblock family of add-ons in different configurations: without subscriptions, with a subscription against counters (cnt), and 3 subscriptions - default RuAdlist + Easylist , BitBlock vs. social media widgets and cnt vs. counters. I note

    Firefox 17.0.1 memory consumption (in megabytes) with different Adblock add-ons
    subscriptions01 (cnt)3 (ruad + easy, bitblock, cnt)
    adblock lite 1.4.3
    blank585868
    yandex.ru7373139
    growth151571
    adblock edge 2.0.2
    blank5657119
    yandex.ru7369129
    growth1712ten
    adblock plus 2.2.1
    blank5657116
    yandex.ru7069128
    growth141212
    As can be seen from the table (except that the results are generally puzzling): the initial assumptions about optimization and lightness are confirmed in practice exactly the opposite: the most ordinary mainstream Adblock plus turns out to be the most economical, and the lite version, despite its the name consumes memory more than anyone, and, in addition, noticeably slows down the rendering of heavy pages, such as searching for images in Yandex.
    Why is this so? It's all about the versions of Adblock plus, which are the basis of alternative add-ons - they are all older, and new ones are better optimized (an infrequent phenomenon in the software world). In versions 1.x, the rule cache was used as a javascript file, this solution turned out to be unsuccessful in terms of performance and was abandoned.

    Take a look inside XPI. In chrome / locale there are localizations for all kinds of languages, mentioned above. Of greatest interest is the defaults folder. By modifying the prefs.js file, you can automate the setting of all settings for Adblock, which is convenient for mass deployment. The syntax is standard - like the settings of the browser itself. The following settings are recommended: (For more information on these and other parameters in prefs.js read here: adblockplus.org/en/preferences ) Unfortunately, the add-on parameters cannot be set in advance in the settings file of the browser itself (for example, as in my previous article ) - when the first boot of the add-on, it overwrites all the predefined parameters to default. The task is solved only by putting the modified prefs.js back into XPI.
    pref("extensions.adblockplus.savestats", false);
    pref("extensions.adblockplus.hideContributeButton", true);
    pref("extensions.adblockplus.patternsbackups", 2);
    pref("extensions.adblockplus.subscriptions_exceptionsurl", ""); //обнуляем урл белого списка "приемлемой рекламы"
    pref("extensions.adblockplus.subscriptions_exceptionscheckbox", false);// бесполезно: не отключает подписку приемлемой рекламы, а только показывает белый список явно как подписку вместо галки



    Own rules of the game


    Standard subscriptions are not only heavyweight, they do not block the google analytics scripts that are heavy and abusive of espionage, which are available on almost every site, which means that you need to write at least one rule manually. And if you write one thing - then why (knowing the reg. Expressions) and not all?
    It was convenient to group the rules by topic: in case of violation of the usability of the pages, it is easier to localize the problem by disabling the rules block by block. The following lists are based on both ready-made subscriptions and own developments in the field of “anti-banner” rules for Squid. Adblock's interface is very friendly with the clipboard - it allows you to copy selected rules in the form of text strings or paste the copied text in the form of rules.

    custom
    ///rs[0-9-03?\.mail\.ru/[bd.BIZ/
    || radar.imgsmail.ru ^
    /images.rambler.ru/(n|upl)//
    || rl0.ru $ domain = ~ rambler.ru
    || hhcdn.ru/nposter/*
    || pics.top.rbc.ru/top_pics/v2/jslib/ch2.js
    || pics.rbc.ru/js/api.js
    | http: //pics.rbc.ru/*/afm/img.gif?
    || pics.rbc.ru/banners/*
    || loadup.ru / * $ third-party
    || myuniques.ru ^ $ third-party
    || oskale.ru ^ $ third-party
    || partner.pladform.ru ^ $ third-party
    || ningme.ru/*video2*$third-party
    ||klonedaset.org^$third-party
    ||vmblock.net^$third-party
    ||wigetmedia.com/$script,third-party
    @@||adv.magna.ru/$script
    @@||swa.mail.ru/cgi-bin/*$script
    ||backromy.com^$script,third-party
    ||cs.sopital.com^$third-party
    ||awaps.yandex.ru^
    ||stream.traflux.info^$third-party
    ||corcon.ru/style/*
    ||beats.palaven.info^
    ||cdn.vidigital.ru/media/$object-subrequest
    ||pay-hit.com^$script,third-party
    ||ucoz.net/ads_w*.js
    ||ucoz.net/src/*$script,stylesheet
    ||spotsniper.ru/?*$script,third-party
    ||themodules.ru^$third-party
    ||bs.yandex.ru/show/*$script,third-party
    ||am10.ru^$script
    ||cedexis$script,third-party
    ||mythings.com^$third-party
    ||criteo.$third-party
    ||image.subscribe.ru/advert/

    counters
    //count(er)?\[\?\.]/$third-party
    /counters?
    ||google-analytics.com/*.js$third-party,script
    ||google-analytics.com/__utm.gif?
    ||bs.yandex.ru/informer
    ||tns-counter.ru/V
    /top100^
    /xtcore.js
    /xgemius.js
    ///cnt\[10]*\./$third-party
    /cnt.$third-party
    ||kiks.yandex.
    ||mc.yandex.ru^
    ||yandex.ru/cycounter?*
    counter.rambler.ru/
    ||yabs.yandex.ru/count/
    ||an.yandex.ru^
    ||top$third-party
    ||i.bigmir.net/cnt/
    ||count.ru/c$third-party
    ||hit.gemius.pl
    ||c.bigmir.net^
    ||spylog.$third-party
    ||hotlog.$third-party
    ||openstat.net/$third-party
    ||web-visor.com/c.js
    ||b.scorecardresearch.com/$third-party
    ||atdmt.com^$third-party
    ||amung.us^$third-party
    ||montblanc.rambler.ru^$script
    ||top-fwz1.mail.ru^
    ###counters

    uni-banners
    /\D(?:3\[123]\[-_x]88|88\[-_x]3\[123])\D/$domain=~money.yandex.ru
    /\[.-/]1\[26]0\[-x_]600?\[.-/]/
    /\[.-/]468\[-x_]\[68]0\[.-/]/
    /\[.-/]300\[-x_]250\[.-/]/
    /\[.-/]728\[-x_]90\[.-/]/
    /240x400*.swf
    /200x300*.swf
    /(200|468)_1\.swf/
    ///ad\[sv]?\[0-9]?\./
    //e?rle\.cgi/
    /erle.js
    ||reklama.$script,subdocument,object
    ||advert$third-party
    ||banner$third-party
    ||adserv$third-party
    /informer^$third-party
    ||pagead$third-party
    /advert.
    /\[/_]banner\.js/$script
    ^banner$third-party
    /pagead^$third-party
    //ad\[sv]?//
    ^adfox$script
    ^adriver$script
    ||*ads.*/$third-party
    /awaps.html
    ^krutilka/$third-party
    ##.b-banner
    ###left_ads
    ###top-ads
    ###bn-bot-wrap
    /*popunder$third-party,script
    ^popunder$image,~image,popup
    /show_ads.js
    /pop?$popup
    ||*pop*/$third-party,popup
    *teaser*/*$third-party,script
    ||tizer$third-party

    banners
    ||yabs.yandex.ru/resource/
    ||adriver.ru/$third-party
    ||googleadservices.com^$third-party
    ||autocontext.begun.ru/
    ||bn.adblender.ru
    ||doubleclick.net/$third-party
    ||directadvert.ru$third-party
    ||tbn.ru$third-party
    ||adwolf.$third-party
    ||dt00.net/$third-party
    ||goodadvert.ru/$third-party
    ||marketgid.com/$third-party
    ||luxup.ru/$third-party
    ||zorkabiz.ru/$third-party
    ||novoteka.ru/$third-party
    ||arbocontext.ru/$third-party
    ||videoclick.ru/$third-party
    ||looksmart.com/$third-party
    ||rorer.ru/$third-party
    ||mixmarket.biz/$third-party
    ||adonweb.ru/$third-party
    ||1100ad.com/$third-party
    ||b2bvideo.ru/js/video.js.php?
    ||molodejj.tv/$third-party
    ||richmedia.yimg.com/
    ||content.medialand.ru/*$third-party
    ||medialand.ru/*$third-party,~script
    ||magna.ru/fcgi/*$third-party
    ||engine.video-link.ru/$third-party
    ||videoclick.ru/$third-party
    ||videoclik.$third-party
    ||b.kavanga.ru/exp?*
    ||rotaban.ru^$third-party
    ||post.rmbn.ru^
    ||intellitxt.com^$script,third-party
    ||content.relax.ru^$third-party
    ||target.smi2.net/client/target.js
    ###sape_okn

    anti-social
    //icon?\[_-](rss|facebook|twitter|gplus|vk)\[-.]/
    /icons/facebook$domain=~facebook.com
    /addthis_widget.
    ||api-public.addthis.com/url/shares.json
    |http://userapi.com/js/api/
    /rss.png
    ||facebook.com/widgets/like$third-party
    ||facebook.com/plugins/*.php?$third-party,subdocument
    ||*.ak.facebook.com/connect/*$subdocument
    /facebook.gif|$domain=~facebook.com
    ||api.facebook.com^$third-party
    ||api.qip.ru$third-party
    ||connect.mail.ru^$third-party
    ||odnoklassniki.ru^$third-party,~stylesheet
    ||stg.odnoklassniki.ru/share/$third-party
    ||odnoklassniki.ru/dk?st.cmd=extOneClickLike
    ||connect.ok.ru/connect.js$third-party
    ||connect.facebook.net/*/all.js$third-party
    ||mystatus.skype.com^
    ||vkontakte.ru/widget_$domain=~vk.com
    ||vk.com/widget_$third-party
    ||vk.com/share.php?*$script,third-party
    ||vk.com/images/upload.gif|$domain=~vk.com
    ||vkontakte.ru/share.php?*
    ||userapi.com^$third-party,domain=~vk.com
    ||stg.odnoklassniki.ru/share/odkl_share.js$third-party
    plusone.js|$third-party
    ||plus.google.com/$subdocument,domain=~google.ru,google.com
    ||google.*/cse/brand?form=
    ||apis.google.com/_/+1/*$third-party
    ||platform.twitter.com/widgets.js$third-party
    ||yandex.st/share/$domain=~yandex.ru
    /widget.js$third-party
    /share.js$third-party,domain=~mail.ru
    ||share.pluso.ru/$third-party
    ||platform.twitter.com/widgets/*$third-party
    ||surfingbird.ru/share/share.min.js
    ||surfingbird.ru/button?*
    ##.g_blank_likes
    ##.googleplus
    ##.g-plus
    ##.twitter
    ##.twitter-follow-button
    ~facebook.com###facebook
    ##.facebook
    ##.fb-like
    ##.vkontakte
    ##.yashare-auto-init
    ##.social-links
    ##.fb-like-box
    ##.gmt-social-buttons
    ##.post_share
    ##.share-button
    ##.share_block
    ##.sharebar
    ##.social-links
    ###social-media
    ###b_soc
    ~mts.ru##.social
    ##.addthis_toolbox

    Anti-adblock
    /blockblock*$script
    /anti_ab.
    /adb*_detector.
    /*adblock$script,domain=~adblockplus.org

    The custom group is the rules for certain sites and a kind of dump for new rules that are created visually through the “Adblock plus: block image ...” context menu: a new rule created in this way is added to the first filter group at the end of the list.

    So, all this, it would seem, a considerable number of rules actually turn into INI and CSS, in total weighing only 9.5 kb. Which is about 200 times (!) Less than the option with three subscriptions. With the same result.

    A lazy implementation of this strategy is also possible: a standard subscription is added against the counters ruadlist.googlecode.com/svn/trunk/cntblock.txt - it weighs a modest 12 kb and, which is good, is updated by the developer, and several rules are written manually: against google analytics, several universal rules against banners and against the 1-2 most common scripts of social networks:
    example of a very simple set of rules
    ||google-analytics.com/$third-party
    /pagead^$third-party
    ||googleadservices.com^$third-party
    ///adv?[0-9]?\./$third-party
    ||*ads.*/$third-party
    //e?rle\./
    banner$third-party
    /informer^$third-party
    ^adfox$script
    ^adriver$script
    ||adfox.$third-party
    ||adriver.$third-party
    ||adwolf.$third-party
    ||connect.facebook.net/*/all.js
    ||google.com/js/plusone.js$third-party
    ||doubleclick.net^$third-party
    ||autocontext.begun.ru^$third-party
    ||directadvert.ru^$third-party
    /blockBlock*$script

    In the organization’s network, you can create your own subscription. This is not difficult: the resulting patterns.ini is taken from the adblockplus folder, in it the contents of each [Subscription filters] section are uploaded to the web server as a separate TXT file with the [Adblock Plus 2.0] header on the first line. You can automatically connect your subscriptions, for example, by placing patterns.ini in the adblockplus folder on each machine. patterns.ini (for example, the most minimal one) can be crammed directly into XPI - in the same defaults folder where we (see above) replaced prefs.js.

    Help in Russian on the syntax of rules for Adblock Plus

    Download patterns.ini with the above rules

    Also popular now: