zoukankan      html  css  js  c++  java
  • Writing Adblock Plus filters

    【 使用Adblock Plus编辑过滤规则】

    中文版见下:(不过中文的不是最新版,有些规则出出入的)

    http://code.google.com/p/adblock-chinalist/wiki/Writing_Adblock_Plus_filters

    英文原版(推荐):

    http://adblockplus.org/en/filters

    自己使用的一个去文字广告的例子:

    IM520文字广告去除练习:

    OX.com##div#ad_text

    或者

    OX.com##div.ad_text

    远离很简单的,##表示去除元素广告,div表示元素div,#ad_text和.ad_text表示ID和Class为ad_text的元素,搞定。

    以下为英文原文中个人用到部分:

    Element hiding

    Basic rules

    Sometimes you will find advertisements that can't be blocked because they are embedded as text in the web page itself. If you look at the source code of the web page you might find something like this:

    <div class="textad"> Cheapest tofu, only here and now! </div> <div id="sponsorad"> Really cheap tofu, click here! </div> <textad> Only here you get the best tofu! </textad> 


    You need to download the web page so you will necessarily download the advertisements. All you can do here is to hide the advertisement so you don't need to see it. That's what element hiding is meant for.

    The first advertisement above is contained inside a div element with class attribute "textad". The following rule will hide exactly this combination: ##div.textad. Here ## marks an element hiding rule while the rest is a selector identifying the elements that need to be hidden. You can hide elements by their id attribute similarly, ##div#sponsorad will hide the second advertisement. You don't need to specify the element name, the rule ##*#sponsorad will work just as well. And you can hide elements by element name only, e.g. ##textad for the third advertisement.

    The Element Hiding Helper extension helps selecting the correct element and writing the corresponding rule without having to view the source code of the page. Basic HTML knowledge is useful nevertheless.

    Note: Element hiding works very differently from normal filters. This has the implication that no wildcards are supported in element hiding rules.

    Limiting rules to certain domains

    Usually you want to hide a specific ad on one specific site, you don't want your rule to be applied on other sites. For example the rule ##*.sponsor might hide valid code on some sites. But if you write it as example.com##*.sponsor it will be applied on http://example.com/ and http://something.example.com/ but not on http://example.org/. You can also specify multiple domains — simply separate them with commas: domain1.example,domain2.example,domain3.example##*.sponsor.

    If a domain name is preceded with "~", the rule will not be applied on pages from this domain (requires Adblock Plus 1.1 or higher). For example, ~example.com##*.sponsor will be be applied on pages from any domain but "example.com" and example.com,~foo.example.com##*.sponsor makes the rule apply on "example.com" domain with the exception of "foo.example.com" subdomain.

    Note: Due to the way how element hiding is implemented, you really can only limit it to full domain names. You cannot use any other part of the address and you cannot use domain as a replacement for domain.example,domain.test.

    Note: Element hiding rules with domain limitation can be used to hide browser's user interface elements as well. For example the filter rule browser##menuitem#javascriptConsole will hide the JavaScript Console entry in Firefox's Tools menu.

    Attribute selectors

    Some advertisers don't make it easy for you — their text advertisements have neither an id nor a class attribute. You can use other attributes to hide those, for example ##table[width="80%"] will hide tables with width attribute set to 80%. If you don't want to specify the full value of the attribute, ##div[title*="adv"] will hide all div elements with title attribute containing the string "adv". You can also check the beginning and the end of an attribute, for example ##div[title^="adv"][title$="ert"] will hide div elements with title starting with "adv" and ending with "ert". As you see, you can also use multiple conditions — table[width="80%"][bgcolor="white"] will match tables with width attribute set to 80% and bgcolor attribute set to white.

    Advanced selectors

    In general, any CSS selector supported by Firefox can be used for element hiding. For example the following rule will hide anything following a div element with class "adheader": ##div.adheader + *. For a full list of CSS list see W3C CSS specification (note that not all selectors are supported by Firefox yet).

    Note: This functionality is for advanced users only, you should be comfortable with CSS selectors to use it. Adblock Plus won't be able to check the syntax of the selector you are adding, if you use invalid CSS syntax you might break other (valid) rules you have. Check JavaScript Console for CSS errors.

    Simplified element hiding syntax

    Adblock Plus supports simplified element hiding syntax (e.g. #div(id=foo)) for backwards compatibility only. Using this syntax is discouraged, usual CSS selectors are preferred. Support for this syntax might be removed at some point.

     
  • 相关阅读:
    xml配置文件使用-读取、转换
    .NET 4.0 缓存
    jQuery分页插件pagination.js 笔记
    Spring源码
    Shell编程(字符串篇)
    Linux DNS 相关
    Shell将命令执行结果写入文件
    Linux安装GCC
    Linux网络安全
    产品经理基础
  • 原文地址:https://www.cnblogs.com/xfiver/p/1875492.html
Copyright © 2011-2022 走看看