问题
How adblock plus blocks advertisements in the web? I saw it inject some css that hide the advertisement, but I think that he does more than that - for example blocking http request..
回答1:
They give a brief idea of it here: http://chromeadblock.org/extensions/adblock-for-chrome/
However no real details. I think what they do is, to check css class and id's for badwords, like: advert, ad, sponsored .... Furthermore, they'll have a list of major Ad Servers like AdWords etc. and simply block those IP's / domains from being loaded. Afterwards it seems like it calculates the dimensions of the removed ad and fills it up with a blank CSS.
Maybe thats not how they do it, but that is how I would do it.
回答2:
Adblock Plus has two mechanisms, to block content on websites:
Element hiding: A CSS snippet is injected in the website, to hide elements that are supposed to be blocked. That way the ads are completely removed from the rendered page, so that the areas otherwise used for ads will now be used for the actual content of the web page, and even content that is part of the web page itself (like text ads) can be blocked. However this doesn't prevent resources from loading in the first place.
Request blocking: HTTP requests for retrieving resources that are supposed to be blocked will be prevented from loading. This will make the page load faster, reduce traffic, and even enables blocking content that is loaded from within Flash, like the video ads on YouTube.
Both, the elements to hide on given websites, and the URLs to block, are controlled by filter lists. By default Adblock Plus will use EasyList. But you are free to setup your own filter rules or configure other filter lists.
回答3:
Here it is how it is done: https://adblockplus.org/en/faq_internal#elemhide
They just disable the block the adblock with the list of ids that they have in hand at user agent stylesheet i.e. at your browser level with its JS.
来源:https://stackoverflow.com/questions/8715904/how-adblock-plus-works-in-chrome