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> |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 <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> | 174 <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> |
175 <li> | 175 <li> |
176 {{s75 <code><fix>donottrack</fix></code> — for any address matching a bloc
king rule with | 176 {{s75 <code><fix>donottrack</fix></code> — for any address matching a bloc
king rule with |
177 this option and not matching any exception rules with this option a | 177 this option and not matching any exception rules with this option a |
178 <a href="http://donottrack.us/">Do-Not-Track header</a> will be sent (requ
ires | 178 <a href="http://donottrack.us/">Do-Not-Track header</a> will be sent (requ
ires |
179 Adblock Plus 1.3.5 or higher).}} {{s76 For backwards compatibility it is r
ecommended | 179 Adblock Plus 1.3.5 or higher).}} {{s76 For backwards compatibility it is r
ecommended |
180 to use this option in combination with contradicting type options, this wi
ll prevent this | 180 to use this option in combination with contradicting type options, this wi
ll prevent this |
181 filter from blocking anything in earlier Adblock Plus versions: | 181 filter from blocking anything in earlier Adblock Plus versions: |
182 <code><fix>*$donottrack,image,~image</fix></code>}} | 182 <code><fix>*$donottrack,image,~image</fix></code>}} |
183 </li> | 183 </li> |
| 184 <li> |
| 185 {{rewriteoption Rewrite the URL with the option <code><fix>rewrite=</fix><
/code>. You may want to create a regular expression filter to perform the rewrit
e operation. In that case, you can use <code><fix>$n</fix></code> in the rewrite
argument, with n being a number between 1 and 100, to insert the n-th parenthes
is submatch of the filter regular expression. Anything not explicitly matched by
it will be added in the rewritten string. For example <code><fix>/(server.com\/
assets\/file.php)\?.*$/$rewrite=$1</fix></code> will strip everything that comes
after ".php" and redirects the request to the resulting URL. If there is no que
ry parameter (i.e. no '?'), this filter won't match. The rewrite parameter has t
he same syntax as JavaScript’s <code><fix>String.prototype.replace()</fix></code
> when using a regular expression instead of a substring. If both, a filter with
/without <code><fix>$rewrite</fix></code> option matches, the behavior is undefi
ned, i.e. the request might either be blocked or redirected. (Adblock Plus 3.2 o
r higher required.)}} |
| 186 </li> |
184 </ul> | 187 </ul> |
185 | 188 |
186 <h4 id="regexps">{{s77 Using regular expressions}}</h4> | 189 <h4 id="regexps">{{s77 Using regular expressions}}</h4> |
187 | 190 |
188 <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> | 191 <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> |
189 | 192 |
190 <p>{{s80 <em>Note</em>: For performance reasons it is recommended not to use r
egular expressions if they can be avoided.}}</p> | 193 <p>{{s80 <em>Note</em>: For performance reasons it is recommended not to use r
egular expressions if they can be avoided.}}</p> |
191 | 194 |
192 <h2 id="elemhide">{{s81 Element hiding}}</h2> | 195 <h2 id="elemhide">{{s81 Element hiding}}</h2> |
193 | 196 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 {{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:}} | 302 {{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:}} |
300 </p> | 303 </p> |
301 | 304 |
302 <pre> | 305 <pre> |
303 /index.html?q=foo\0www.example.com\0Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv
:30.0) Gecko/20100101 Firefox/30.0 | 306 /index.html?q=foo\0www.example.com\0Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv
:30.0) Gecko/20100101 Firefox/30.0 |
304 </pre> | 307 </pre> |
305 | 308 |
306 <p> | 309 <p> |
307 {{s111 Finally, generate the signature for this string by using the signature
algorithm SEC_OID_ISO_SHA_WITH_RSA_SIGNATURE (default when using OpenSSL).}} | 310 {{s111 Finally, generate the signature for this string by using the signature
algorithm SEC_OID_ISO_SHA_WITH_RSA_SIGNATURE (default when using OpenSSL).}} |
308 </p> | 311 </p> |
OLD | NEW |