OLD | NEW |
(Empty) | |
| 1 title=Writing Adblock Plus filters |
| 2 |
| 3 |
| 4 <p>{{s1 Current Adblock Plus versions allow you to "tweak" your filters in many
different ways. This document explains the choices that you have and how they ca
n be used.}}</p> |
| 5 |
| 6 <p>{{s2 <em>Disclaimer</em>: All filter examples given here are really only ex
amples and are not meant to be used.}}</p> |
| 7 |
| 8 <h2 id="introduction">{{s3 Introduction to Adblock Plus filters}}</h2> |
| 9 |
| 10 <p>{{s4 The options described in this section should be enough for users who h
ave to create a filter occasionally.}}</p> |
| 11 |
| 12 <h3 id="basic">{{s5 Basic filter rules}}</h3> |
| 13 |
| 14 <p>{{s6 The most trivial filter you can define is of course the address of ban
ner you want to block. However, often this address changes every time you open a
page. For example it could be <code><fix>http://example.com/ads/banner123.gif</
fix></code> where 123 is a random number. Here blocking the complete address won
't help you, you need a more general filter — like <code><fix>http://example.com
/ads/banner*.gif</fix></code>. Or maybe even <code><fix>http://example.com/ads/*
</fix></code>.}}</p> |
| 15 |
| 16 <p>{{s7 <em>Note</em>: Make sure that you are not replacing too much by wildca
rds. The filter <code><fix>http://example.com/*</fix></code> will definitely blo
ck all banners but it will also block everything else from example.com that you
still might want to see.}}</p> |
| 17 |
| 18 <h3 id="whitelist">{{s8 Defining exception rules}}</h3> |
| 19 |
| 20 <p>{{s9 Sometimes you will notice that one of your filters that is usually wor
king quite well blocks in some case blocks something that it shouldn't be blocki
ng. You don't want to remove this filter but you still don't want it to match in
this one case.}}</p> |
| 21 |
| 22 <p>{{s10 That's what exception rules are good for — they allow you to define c
ases where filters shouldn't be applied. For example if you are unhappy with you
r filter <code><fix>adv</fix></code> blocking <code><fix>http://example.com/advi
ce.html</fix></code>, you can define an exception rule <code><fix>@@advice</fix>
</code>. Exception rules are no different from filter rules, you can use wildcar
ds or regular expressions. You only have to precede them by <code><fix>@@</fix><
/code> to indicate an exception rule.}}</p> |
| 23 |
| 24 <p>{{s11 Exception rules can do more. If you specify <code><fix>$document</fix
></code> option you will get an exception for the entire page. For example, if y
our exception rule is <code><fix>@@||example.com^$document</fix></code> and you
open some page from example.com — Adblock Plus will be entirely disabled on this
page and nothing will be blocked.}}</p> |
| 25 |
| 26 <h3 id="anchors">{{s12 Matching at beginning/end of an address}}</h3> |
| 27 |
| 28 <p>{{s13 Usually Adblock Plus treats every filter as if it had a wildcard at i
ts beginning and end, e.g. there is not difference between the filters <code><fi
x>ad</fix></code> and <code><fix>*ad*</fix></code>. While this is usually unprob
lematic, sometimes you wish that the filter you defined only matches at the begi
nning or end of an address. For example you might want to block all Flash, but i
f you add the filter <code><fix>swf</fix></code> the address <code><fix>http://e
xample.com/swf/index.html</fix></code> will also be blocked.}}</p> |
| 29 |
| 30 <p>{{s14 Solution to this problem: add a pipe symbol to the filter to show tha
t there should be definitely the end of the address at this point. For example t
he filter <code><fix>swf|</fix></code> will block <code><fix>http://example.com/
annoyingflash.swf</fix></code> but not <code><fix>http://example.com/swf/index.h
tml</fix></code>. And the filter <code>|http://baddomain.example/</code> will bl
ock <code>http://baddomain.example/banner.gif</code> but not <code>http://gooddo
main.example/analyze?http://baddomain.example</code>.}}</p> |
| 31 |
| 32 <p id="flexible-anchors">{{s15 Sometimes one wants to block <code><fix>http://
example.com/banner.gif</fix></code> as well as <code><fix>https://example.com/ba
nner.gif</fix></code> and <code><fix>http://www.example.com/banner.gif</fix></co
de>. This can be achieved by putting two pipe symbols in front of the filter whi
ch makes sure the filter matches at the beginning of the domain name: <code><fix
>||example.com/banner.gif</fix></code> will block all these addresses while not
blocking <code>http://badexample.com/banner.gif</code> or <code>http://gooddomai
n.example/analyze?http://example.com/banner.gif</code> (requires Adblock Plus 1.
1 or higher).}}</p> |
| 33 |
| 34 <h3 id="separators">{{s16 Marking separator characters}}</h3> |
| 35 |
| 36 <p>{{s17 Often you need to accept any separator character in a filter. For exa
mple, you might write a filter that blocks <code><fix>http://example.com/</fix><
/code> and <code><fix>http://example.com:8000/</fix></code> but not <code><fix>h
ttp://example.com.ar/</fix></code>. Here the symbol ^ can be used as a placehold
er for a single separator character: <code><fix>http://example.com^</fix></code>
(requires Adblock Plus 1.1 or higher).}}</p> |
| 37 |
| 38 <p>{{s18 Separator character is anything but a letter, a digit, or one of the
following: <fix>_ - . %</fix>. The end of the address is also accepted as separa
tor. In the following example all separator characters are shown in red:}} http:
<b style="color: red;">//</b>example.com<b style="color: red;">:</b>8000<b style
="color: red;">/</b>foo.bar<b style="color: red;">?</b>a<b style="color: red;">=
</b>12<b style="color: red;">&</b>b<b style="color: red;">=</b>%D1%82%D0%B5%
D1%81%D1%82{{s19 . So this address can be blocked with the filter <code><fix>^ex
ample.com^</fix></code> or <code><fix>^%D1%82%D0%B5%D1%81%D1%82^</fix></code> or
<code><fix>^foo.bar^</fix></code>.}}</p> |
| 39 |
| 40 <h3 id="comments">{{s20 Comments}}</h3> |
| 41 |
| 42 <p>{{s21 Any rule that starts with an exclamation mark is considered a comment
. It will still show up in the filter list but in grey instead of black. Adblock
Plus will ignore this rule for actual blocking so it is safe to write there wha
tever you want. You can place a comment rule above a real filter to describe wha
t it is doing. Or you can put a comment on top of your filter list stating your
authorship (most filter list authors do that).}}</p> |
| 43 |
| 44 <h4 id="special-comments">{{s22 Special comments}}</h4> |
| 45 |
| 46 <p> |
| 47 {{s23 Special comments will only have an effect in downloaded filter lists, no
t in custom filters.}} {{s24 They can set a number |
| 48 of parameters for the filter list:}} |
| 49 </p> |
| 50 |
| 51 <ul> |
| 52 <li> |
| 53 <p> |
| 54 <code>! Homepage: http://example.com/</code> |
| 55 </p> |
| 56 <p> |
| 57 {{s25 This comment determines which webpage should be linked as filter lis
t homepage.}} |
| 58 </p> |
| 59 </li> |
| 60 <li> |
| 61 <p> |
| 62 <code>! Title: FooList</code> |
| 63 </p> |
| 64 <p> |
| 65 {{s26 This comment sets a fixed title for the filter list.}} {{s27 If this
comment is present the user will no longer be able to change |
| 66 the title.}} |
| 67 </p> |
| 68 </li> |
| 69 <li> |
| 70 <p> |
| 71 <code>! Expires: 5 days</code> |
| 72 </p> |
| 73 <p> |
| 74 {{s28 This comment sets the update interval for the filter list, the value
can be given in days (e.g. <code><fix>5 days</fix></code>) or hours |
| 75 (e.g. <code><fix>8 hours</fix></code>).}} {{s29 Any value between 1 hour a
nd 14 days is possible.}} {{s30 Note that the update |
| 76 will not necessarily happen after this time interval.}} {{s31 The actual u
pdate time is slightly randomized and depends on |
| 77 some additional factors to reduce server load.}} |
| 78 </p> |
| 79 </li> |
| 80 <li> |
| 81 <p> |
| 82 <code>! Checksum: OaopkIiiAl77sSHk/VAWDA</code> |
| 83 </p> |
| 84 <p> |
| 85 {{s32 This comment makes sure that accidental corruption of the data won't
result |
| 86 in broken filters.}} {{s33 For example, some firewall software might modif
y the filter <code>*/adnetwork/*</code> on download |
| 87 in an attempt to protect the user against ads.}} {{s34 It will remove part
of the filter so that Adblock Plus will only see |
| 88 the filter}} <code>**</code>{{s35 .}} {{s36 A checksum comment in the filt
er list protects against this scenario, any modifications |
| 89 will have the result that the checksum no longer matches and Adblock Plus
will ignore the data.}} |
| 90 </p> |
| 91 <p> |
| 92 {{s37 To calculate the checksum the following steps need to be performed:}
} |
| 93 </p> |
| 94 <ul> |
| 95 <li>{{s38 Remove the existing checksum comment if any.}}</li> |
| 96 <li>{{s39 Encode filter list text using UTF-8 encoding.}}</li> |
| 97 <li>{{s40 Convert all line breaks to Unix style (replace <code><fix>\r</fi
x></code> by <code><fix>\n</fix></code> if present).}}</li> |
| 98 <li>{{s41 Remove empty lines (replace sequences of the <code><fix>\n</fix>
</code> character by a single <code><fix>\n</fix></code> character).}}</li> |
| 99 <li>{{s42 Calculate the base64-encoded MD5 checksum of the text, remove tr
ailing}} <code>=</code> {{s43 characters if any.}}</li> |
| 100 </ul> |
| 101 <p> |
| 102 {{s44 You can also have a look at the Python-based reference implementatio
ns to |
| 103 <a href="https://hg.adblockplus.org/adblockplus/file/tip/validateChecksum.
py">validate a checksum</a> and to |
| 104 <a href="https://hg.adblockplus.org/adblockplus/file/tip/addChecksum.py">a
dd a checksum to a file</a>.}} |
| 105 </p> |
| 106 </li> |
| 107 <li> |
| 108 <p> |
| 109 <code>! Redirect: http://example.com/list.txt</code> |
| 110 </p> |
| 111 <p> |
| 112 {{s45 This comment indicates that the filter list has moved to a new downl
oad address.}} {{s46 Adblock Plus will ignore any file |
| 113 contents beyond that comment and immediately try downloading from the new
address.}} {{s47 In case of success the address |
| 114 of the filter list will be updated in the settings.}} {{s48 This comment i
s ignored if the new address is the same as the |
| 115 current address, meaning that it can be used to enforce the "canonical" ad
dress of the filter list.}} |
| 116 </p> |
| 117 </li> |
| 118 <li> |
| 119 <p> |
| 120 <code>! Version: 1234</code> |
| 121 </p> |
| 122 <p> |
| 123 {{s49 This comment defines a numerical version of the filter list.}} {{s50
This version number will be displayed in issue reports |
| 124 and can be used to verify that the report refers to the current version of
the filter list.}} |
| 125 </p> |
| 126 </li> |
| 127 </ul> |
| 128 |
| 129 <h3 id="advanced">{{s51 Advanced features}}</h3> |
| 130 |
| 131 <p>{{s52 The features described in this section are usually used only by power
users and filterlist creators. Feel free to skip it.}}</p> |
| 132 |
| 133 <h4 id="options">{{s53 Specifying filter options}}</h4> |
| 134 |
| 135 <p>{{s54 Adblock Plus allows you to specify a number of options to modify the
behavior of a filter. You list these options separated with commas after a dolla
r sign ($) at the end of the filter, for example:}}</p> |
| 136 |
| 137 <pre> |
| 138 */ads/*$script,match-case |
| 139 </pre> |
| 140 |
| 141 <p>{{s55 Here <code><fix>*/ads/*</fix></code> is the actual filter and <code><
fix>script</fix></code> and <code><fix>match-case</fix></code> are its options.
Currently the following options are supported:}}</p> |
| 142 |
| 143 <ul> |
| 144 <li>{{s56 Type options: determine which types of elements a filter can block
(or whitelist in case of an exception rule). Multiple type options can be speci
fied to indicate that the filter should be applied to several types of elements.
Possible types are:}} |
| 145 <ul> |
| 146 <li>{{s57 <code><fix>script</fix></code> — external scripts loaded via H
TML script tag}}</li> |
| 147 <li>{{s58 <code><fix>image</fix></code> — regular images, typically load
ed via HTML img tag}}</li> |
| 148 <li>{{s59 <code><fix>stylesheet</fix></code> — external CSS stylesheet f
iles}}</li> |
| 149 <li>{{s60 <code><fix>object</fix></code> — content handled by browser pl
ugins, e.g. Flash or Java}}</li> |
| 150 <li>{{xmlhttprequest <code><fix>xmlhttprequest</fix></code> — requests s
tarted using the <a href="https://xhr.spec.whatwg.org/"><code><fix>XMLHttpReques
t</fix></code> object</a> or <a href="https://fetch.spec.whatwg.org/"><code><fix
>fetch()</fix></code> API</a>}}</li> |
| 151 <li>{{s63 <code><fix>object-subrequest</fix></code> — requests started b
y plugins like Flash}}</li> |
| 152 <li>{{s64 <code><fix>subdocument</fix></code> — embedded pages, usually
included via HTML frames}}</li> |
| 153 <li>{{ping <code><fix>ping</fix></code> — requests started by <a href="h
ttps://developer.mozilla.org/docs/Web/HTML/Element/a#attr-ping"><code><fix><a
ping></fix></code></a> or <a href="https://developer.mozilla.org/docs/Web/AP
I/Navigator/sendBeacon"><code><fix>navigator.sendBeacon()</fix></code></a> (Adbl
ock Plus 2.7.1 or higher required)}}</li> |
| 154 <li>{{websocket <code><fix>websocket</fix></code> — requests initiated v
ia <a href="https://developer.mozilla.org/docs/Web/API/WebSocket"><code><fix>Web
Socket</fix></code> object</a> (Adblock Plus 2.8 or higher required)}}</li> |
| 155 <li>{{s65 <code><fix>document</fix></code> — the page itself (only <a hr
ef="#whitelist">exception rules</a> can be applied to the page)}}</li> |
| 156 <li>{{s66 <code><fix>elemhide</fix></code> — for exception rules only, s
imilar to <code><fix>document</fix></code> but only disables <a href="#elemhide"
>element hiding rules</a> on the page rather than all filter rules (Adblock Plus
1.2 or higher required)}}</li> |
| 157 <li>{{generichide <code><fix>generichide</fix></code> — for exception ru
les only, similar to <code><fix>elemhide</fix></code> but only disables <a href=
"#generic-specific">generic</a> element hiding rules on the page (Adblock Plus 2
.6.12 or higher required)}}</li> |
| 158 <li>{{genericblock <code><fix>genericblock</fix></code> — for exception
rules only, just like <code><fix>generichide</fix></code> but disables <a href="
#generic-specific">generic</a> blocking rules (Adblock Plus 2.6.12 or higher req
uired)}}</li> |
| 159 <li>{{s67 <code><fix>other</fix></code> — types of requests not covered
in the list above}}</li> |
| 160 </ul> |
| 161 {{deprecated-options The type options <code><fix>background</fix></code>, |
| 162 <code><fix>xbl</fix></code> and <code><fix>dtd</fix></code> are outdated |
| 163 and should no longer be used.}} |
| 164 </li> |
| 165 <li>{{s69 Inverse type options: specify the element types the filter should
<strong>not</strong> be applied to. Possible inverse type options: <code><fix>~s
cript</fix></code>, <code><fix>~image</fix></code>, <code><fix>~stylesheet</fix>
</code>, <code><fix>~object</fix></code>, <code><fix>~xmlhttprequest</fix></code
>, <code><fix>~object-subrequest</fix></code>, <code><fix>~subdocument</fix></co
de>, <code><fix>~document</fix></code>, <code><fix>~elemhide</fix></code>, <code
><fix>~other</fix></code>}}</li> |
| 166 <li>{{s70 Restriction to third-party/first-party requests: If the <code><fix
>third-party</fix></code> option is specified, the filter is only applied to req
uests from a different origin than the currently viewed page. Similarly, <code><
fix>~third-party</fix></code> restricts the filter to requests from the same ori
gin as the currently viewed page.}}</li> |
| 167 <li>{{s71 Domain restrictions: The option <code><fix>domain=example.com</fix
></code> means that the filter should only be applied on pages from "example.com
" domain. Multiple domains can be specified using "|" as separator: with the opt
ion <code><fix>domain=example.com|example.net</fix></code> the filter will only
be applied on pages from "example.com" or "example.net" domains. If a domain nam
e is preceded with "~", the filter should <strong>not</strong> be applied on pag
es from this domain. For example, <code><fix>domain=~example.com</fix></code> me
ans that the filter should be applied on pages from any domain but "example.com"
and <code><fix>domain=example.com|~foo.example.com</fix></code> restricts the f
ilter to the "example.com" domain with the exception of "foo.example.com" subdom
ain.}}</li> |
| 168 <li> |
| 169 {{s72 Sitekey restrictions: The option <code><fix>sitekey=abcdsitekeydcba<
/fix></code> means that the filter should only be applied on pages that provide
a public key and a signature which can be verified by that very same public key
that is also contained in the filter (but without the trailing =). Multiple site
keys can be specified using "|" as separator: with the option <code><fix>sitekey
=abcdsitekeydcba|bcdesitekeyedcb</fix></code> the filter will only be applied on
pages providing either sitekey "abcdsitekeydcba" or "bcdesitekeyedcb". This is
similar to domain restrictions but allows covering scenarios where a single filt
er should apply to a very large number of domains. Note that sitekey restriction
s require <a href="#sitekey_server">modifications on the server-side</a>.}} |
| 170 </li> |
| 171 <li>{{s73 <code><fix>match-case</fix></code> — makes the filter only apply t
o addresses with matching letter case, e.g. the filter <code><fix>*/BannerAd.gif
$match-case</fix></code> will block <code><fix>http://example.com/BannerAd.gif</
fix></code> but not <code><fix>http://example.com/bannerad.gif</fix></code>.}}</
li> |
| 172 <li>{{s74 <code><fix>collapse</fix></code> — this option will override the g
lobal "Hide placeholders of blocked elements" option and make sure the filter al
ways hides the element. Similarly the <code><fix>~collapse</fix></code> option w
ill make sure the filter never hides the element.}}</li> |
| 173 <li> |
| 174 {{s75 <code><fix>donottrack</fix></code> — for any address matching a bloc
king rule with |
| 175 this option and not matching any exception rules with this option a |
| 176 <a href="http://donottrack.us/">Do-Not-Track header</a> will be sent (requ
ires |
| 177 Adblock Plus 1.3.5 or higher).}} {{s76 For backwards compatibility it is r
ecommended |
| 178 to use this option in combination with contradicting type options, this wi
ll prevent this |
| 179 filter from blocking anything in earlier Adblock Plus versions: |
| 180 <code><fix>*$donottrack,image,~image</fix></code>}} |
| 181 </li> |
| 182 </ul> |
| 183 |
| 184 <h4 id="regexps">{{s77 Using regular expressions}}</h4> |
| 185 |
| 186 <p>{{s79 If you want even more control about what your filters match and what
they don't match, you can use regular expressions. For example the filter <code>
<fix>/banner\d+/</fix></code> will match <code><fix>banner123</fix></code> and <
code><fix>banner321</fix></code> but not <code><fix>banners</fix></code>. You ca
n check out <a href="{{s79-link https://developer.mozilla.org/en/Core_JavaScript
_1.5_Guide/Regular_Expressions#Writing_a_Regular_Expression_Pattern}}">documenta
tion on regular expressions</a> to learn how to write them.}}</p> |
| 187 |
| 188 <p>{{s80 <em>Note</em>: For performance reasons it is recommended not to use r
egular expressions if they can be avoided.}}</p> |
| 189 |
| 190 <h2 id="elemhide">{{s81 Element hiding}}</h2> |
| 191 |
| 192 <h3 id="elemhide_basic">{{s82 Basic rules}}</h3> |
| 193 |
| 194 <p>{{s83 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:}}</p> |
| 195 |
| 196 <pre><div class="textad"> |
| 197 Cheapest tofu, only here and now! |
| 198 </div> |
| 199 <div id="sponsorad"> |
| 200 Really cheap tofu, click here! |
| 201 </div> |
| 202 <textad> |
| 203 Only here you get the best tofu! |
| 204 </textad> |
| 205 </pre> |
| 206 |
| 207 <p>{{s84 You need to download the web page so you will necessarily download th
e 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.}}</p> |
| 208 |
| 209 <p>{{s85 The first advertisement above is contained inside a div element with
class attribute "textad". The following rule will hide exactly this combination:
<code><fix>##div.textad</fix></code>. Here ## marks an element hiding rule whil
e the rest is a selector identifying the elements that need to be hidden. You ca
n hide elements by their id attribute similarly, <code><fix>##div#sponsorad</fix
></code> will hide the second advertisement. You don't need to specify the eleme
nt name, the rule <code><fix>##*#sponsorad</fix></code> will work just as well.
And you can hide elements by element name only, e.g. <code><fix>##textad</fix></
code> for the third advertisement.}}</p> |
| 210 |
| 211 <p>{{s86 The <a href="elemhidehelper">Element Hiding Helper extension</a> help
s selecting the correct element and writing the corresponding rule without havin
g to view the source code of the page. Basic HTML knowledge is useful neverthele
ss.}}</p> |
| 212 |
| 213 <p>{{s87 <em>Note</em>: Element hiding works very differently from normal filt
ers. This has the implication that no wildcards are supported in element hiding
rules.}}</p> |
| 214 |
| 215 <h3 id="elemhide_domains">{{s88 Limiting rules to certain domains}}</h3> |
| 216 |
| 217 <p>{{s89 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 <code><fix>#
#*.sponsor</fix></code> might hide valid code on some sites. But if you write it
as <code><fix>example.com##*.sponsor</fix></code> it will be applied on <code><
fix>http://example.com/</fix></code> and <code><fix>http://something.example.com
/</fix></code> but not on <code><fix>http://example.org/</fix></code>. You can a
lso specify multiple domains — simply separate them with commas: <code><fix>doma
in1.example,domain2.example,domain3.example##*.sponsor</fix></code>.}}</p> |
| 218 |
| 219 <p>{{s90 If a domain name is preceded with "~", the rule will <strong>not</str
ong> be applied on pages from this domain (requires Adblock Plus 1.1 or higher).
For example, <code><fix>~example.com##*.sponsor</fix></code> will be be applied
on pages from any domain but "example.com" and <code><fix>example.com,~foo.exam
ple.com##*.sponsor</fix></code> makes the rule apply on "example.com" domain wit
h the exception of "foo.example.com" subdomain.}}</p> |
| 220 |
| 221 <p>{{s91 <em>Note</em>: 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 <code><fix>domain</fix></code> as a replacement f
or <code><fix>domain.example,domain.test</fix></code>.}}</p> |
| 222 |
| 223 <p>{{s92 <em>Note</em>: Element hiding rules with domain limitation can be use
d to hide browser's user interface elements as well. For example the filter rule
<code><fix>browser##menuitem#javascriptConsole</fix></code> will hide the JavaS
cript Console entry in Firefox's Tools menu.}}</p> |
| 224 |
| 225 <h3 id="elemhide_attributes">{{s93 Attribute selectors}}</h3> |
| 226 |
| 227 <p>{{s94 Some advertisers don't make it easy for you — their text advertisemen
ts have neither an id nor a class attribute. You can use other attributes to hid
e those, for example <code><fix>##table[width="80%"]</fix></code> will hide tabl
es with width attribute set to 80%. If you don't want to specify the full value
of the attribute, <code><fix>##div[title*="adv"]</fix></code> will hide all div
elements with title attribute containing the string "adv". You can also check th
e beginning and the end of an attribute, for example <code><fix>##div[title^="ad
v"][title$="ert"]</fix></code> will hide div elements with title starting with "
adv" and ending with "ert". As you see, you can also use multiple conditions — <
code><fix>table[width="80%"][bgcolor="white"]</fix></code> will match tables wit
h width attribute set to 80% and bgcolor attribute set to white.}}</p> |
| 228 |
| 229 <h3 id="elemhide_css">{{s95 Advanced selectors}}</h3> |
| 230 |
| 231 <p>{{s97 In general, any CSS selector supported by Firefox can be used for ele
ment hiding. For example the following rule will hide anything following a div e
lement with class "adheader": <code><fix>##div.adheader + *</fix></code>. For a
full list of CSS list see <a href="{{s97-link http://www.w3.org/TR/css3-selector
s/}}">W3C CSS specification</a> (note that not all selectors are supported by Fi
refox yet).}}</p> |
| 232 |
| 233 <p>{{s98 <em>Note</em>: This functionality is for advanced users only, you sho
uld be comfortable with CSS selectors to use it. Adblock Plus won't be able to c
heck the syntax of the selector you are adding, if you use invalid CSS syntax yo
u might break other (valid) rules you have. Check JavaScript Console for CSS err
ors.}}</p> |
| 234 |
| 235 <h3 id="elemhide_exceptions">{{s99 Exception rules}}</h3> |
| 236 |
| 237 <p> |
| 238 {{s100 Exception rules can disable existing rules on particular domains.}} {{s
101 These are mostly |
| 239 useful to filter subscription authors who are extending another filter subscri
ption that they |
| 240 cannot change.}} {{s102 For example, the rule <code><fix>##div.textad</fix></c
ode> can be |
| 241 disabled on <code><fix>example.com</fix></code> using the exception rule |
| 242 <code><fix>example.com#@#div.textad</fix></code>.}} {{s103 The combination of
these two |
| 243 rules has exactly the same effect as the single rule |
| 244 <code><fix>~example.com##div.textad</fix></code>.}} {{s104 It is recommended t
hat you use |
| 245 exception rules only when you cannot change an overly general element hiding r
ule, in all the |
| 246 other cases limiting this rule to the necessary domains is preferable.}} |
| 247 </p> |
| 248 |
| 249 <h3 id="elemhide_simplified">{{s105 Simplified element hiding syntax}}</h3> |
| 250 |
| 251 <p>{{s106 Adblock Plus supports simplified element hiding syntax (e.g. <code><
fix>#div(id=foo)</fix></code>) for backwards compatibility only. Using this synt
ax is discouraged, usual CSS selectors are preferred. Support for this syntax mi
ght be removed at some point.}}</p> |
| 252 |
| 253 <h3 id="generic-specific">{{generic-specific-title Generic / Specific filters}
}</h3> |
| 254 |
| 255 <p>{{generic-specific-explanation-p1 With the <code><fix>$generichide</fix></c
ode> and <code><fix>$genericblock</fix></code> filter options the distinction be
tween generic and specific filters becomes important.}}</p> |
| 256 <p>{{generic-specific-explanation-p2 We classify a filter to be <strong>specif
ic</strong> if it matches one or more domains or matches a sitekey. If a filter
has no domains specified (or only domain exceptions) and no sitekey then it coun
ts as <strong>generic</strong>. For example, <code><fix>example.com##div.textad<
/fix></code> is a specific filter, whereas both <code><fix>##div.textad</fix></c
ode> and <code><fix>~example.com##div.textad</fix></code> are generic.}}</p> |
| 257 <p>{{generic-specific-explanation-p3 Note that with blocking rules the domain
must be specified under the $domain option for them to be considered specific. F
or example, <code><fix>||example.com^</fix></code> is considered generic whereas
<code><fix>*/ads/*$domain=example.com</fix></code> is site-specific.}}</p> |
| 258 |
| 259 <h2 id="sitekey_server">{{s107 Implementing a sitekey on the server}}</h2> |
| 260 |
| 261 <p> |
| 262 {{s108 For a <a href="#options">sitekey-restricted filter</a> to apply, a webp
age needs to return base64-encoded versions of the public key and a signature wh
ich Adblock Plus can validate. Currently, this means including them in both the
HTTP response header (<code><fix>X-Adblock-Key: abcdpublickeydcba_abcdsignatured
cba</fix></code>) and the root tag of the document (<code><fix><html data-adb
lockkey="abcdpublickeydcba_abcdsignaturedcba"></fix></code>).}} |
| 263 </p> |
| 264 |
| 265 <p> |
| 266 {{s109 First you need to create a private RSA key (preferably 512 bit to keep
the transfer volume low) and then a DER representation of the public key.}} |
| 267 </p> |
| 268 |
| 269 <p> |
| 270 {{s110 The data used for creating the signature is a concatenated list of requ
est variables (namely URI, host and user agent) separated by the <code><fix>NUL<
/fix></code> character "\0". For example:}} |
| 271 </p> |
| 272 |
| 273 <pre> |
| 274 /index.html?q=foo\0www.example.com\0Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv
:30.0) Gecko/20100101 Firefox/30.0 |
| 275 </pre> |
| 276 |
| 277 <p> |
| 278 {{s111 Finally, generate the signature for this string by using the signature
algorithm SEC_OID_ISO_SHA_WITH_RSA_SIGNATURE (default when using OpenSSL).}} |
| 279 </p> |
OLD | NEW |