OLD | NEW |
1 title=Writing Adblock Plus filters | 1 title=Writing Adblock Plus filters |
2 | 2 |
3 | 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> | 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 | 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> | 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 | 7 |
8 <h2 id="introduction">{{s3 Introduction to Adblock Plus filters}}</h2> | 8 <h2 id="introduction">{{s3 Introduction to Adblock Plus filters}}</h2> |
9 | 9 |
10 <p>{{s4 The options described in this section should be enough for users who h
ave to create a filter occasionally.}}</p> | 10 <p>{{s4 The options described in this section should be enough for users who h
ave to create a filter occasionally.}}</p> |
11 | 11 |
12 <h3 id="basic">{{s5 Basic filter rules}}</h3> | 12 <h3 id="basic">{{s5 Basic filter rules}}</h3> |
13 | 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> | 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 | 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> | 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 | 17 |
18 <h3 id="whitelist">{{s8 Defining exception rules}}</h3> | 18 <h3 id="whitelist">{{s8 Defining exception rules}}</h3> |
19 | 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> | 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 | 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> | 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 | 23 |
24 <p>{{s11 Exception rules can do more. If an exception rule starts with http://
or https:// (optionally with a pipe before it) it will make whole pages an exce
ption. For example, if your exception rule is <code><fix>@@|http://example.com</
fix></code> and you open some page from example.com — Adblock Plus will be entir
ely disabled on this page and nothing will be blocked.}}</p> | 24 <p>{{s11 Exception rules can do more. If an exception rule starts with http://
or https:// (optionally with a pipe before it) it will make whole pages an exce
ption. For example, if your exception rule is <code><fix>@@||http://example.com<
/fix></code> and you open some page from example.com — Adblock Plus will be enti
rely disabled on this page and nothing will be blocked.}}</p> |
25 | 25 |
26 <h3 id="anchors">{{s12 Matching at beginning/end of an address}}</h3> | 26 <h3 id="anchors">{{s12 Matching at beginning/end of an address}}</h3> |
27 | 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> | 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 | 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> | 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 | 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> | 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 | 33 |
34 <h3 id="separators">{{s16 Marking separator characters}}</h3> | 34 <h3 id="separators">{{s16 Marking separator characters}}</h3> |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 {{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:}} | 260 {{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:}} |
261 </p> | 261 </p> |
262 | 262 |
263 <pre> | 263 <pre> |
264 /index.html?q=foo\0www.example.com\0Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv
:30.0) Gecko/20100101 Firefox/30.0 | 264 /index.html?q=foo\0www.example.com\0Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv
:30.0) Gecko/20100101 Firefox/30.0 |
265 </pre> | 265 </pre> |
266 | 266 |
267 <p> | 267 <p> |
268 {{s111 Finally, generate the signature for this string by using the signature
algorithm SEC_OID_ISO_SHA_WITH_RSA_SIGNATURE (default when using OpenSSL).}} | 268 {{s111 Finally, generate the signature for this string by using the signature
algorithm SEC_OID_ISO_SHA_WITH_RSA_SIGNATURE (default when using OpenSSL).}} |
269 </p> | 269 </p> |
OLD | NEW |