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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 <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> | 177 <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> |
178 <li> | 178 <li> |
179 {{s75 <code><fix>donottrack</fix></code> — for any address matching a bloc
king rule with | 179 {{s75 <code><fix>donottrack</fix></code> — for any address matching a bloc
king rule with |
180 this option and not matching any exception rules with this option a | 180 this option and not matching any exception rules with this option a |
181 <a href="http://donottrack.us/">Do-Not-Track header</a> will be sent (requ
ires | 181 <a href="http://donottrack.us/">Do-Not-Track header</a> will be sent (requ
ires |
182 Adblock Plus 1.3.5 or higher).}} {{s76 For backwards compatibility it is r
ecommended | 182 Adblock Plus 1.3.5 or higher).}} {{s76 For backwards compatibility it is r
ecommended |
183 to use this option in combination with contradicting type options, this wi
ll prevent this | 183 to use this option in combination with contradicting type options, this wi
ll prevent this |
184 filter from blocking anything in earlier Adblock Plus versions: | 184 filter from blocking anything in earlier Adblock Plus versions: |
185 <code><fix>*$donottrack,image,~image</fix></code>}} | 185 <code><fix>*$donottrack,image,~image</fix></code>}} |
186 </li> | 186 </li> |
| 187 <li> |
| 188 {{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 <code><fix>n</fix></code> being a number between 1 and 100, to i
nsert the n-th parenthesis submatch of the filter regular expression. Anything n
ot 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 st
rip everything that comes after ".php" and redirects the request to the resultin
g URL. If there is no query string (i.e. no '?'), this filter won't match. The r
ewrite parameter has the same syntax as JavaScript’s <a href="https://developer.
mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Sp
ecifying_a_string_as_a_parameter"><code><fix>String.prototype.replace()</fix></c
ode></a>. The resulting URL must have the same origin; in case it is rewritten t
o a relative URL, the origin gets added back. Also, rewrite for scripts, subdocu
ments, objects, requests from within objects (like Flash) are not possible for s
ecurity reason; even if explicitly stated by the filter. If both, a filter with/
without <code><fix>$rewrite</fix></code> option matches, the behavior is undefin
ed, i.e. the request might either be blocked or redirected. (Adblock Plus 3.2 or
higher required.)}} |
| 189 </li> |
187 </ul> | 190 </ul> |
188 | 191 |
189 <h4 id="regexps">{{s77 Using regular expressions}}</h4> | 192 <h4 id="regexps">{{s77 Using regular expressions}}</h4> |
190 | 193 |
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> | 194 <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> |
192 | 195 |
193 <p>{{s80 <em>Note</em>: For performance reasons it is recommended not to use r
egular expressions if they can be avoided.}}</p> | 196 <p>{{s80 <em>Note</em>: For performance reasons it is recommended not to use r
egular expressions if they can be avoided.}}</p> |
194 | 197 |
195 <h2 id="elemhide">{{s81 Element hiding}}</h2> | 198 <h2 id="elemhide">{{s81 Element hiding}}</h2> |
196 | 199 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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:}} | 305 {{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:}} |
303 </p> | 306 </p> |
304 | 307 |
305 <pre> | 308 <pre> |
306 /index.html?q=foo\0www.example.com\0Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv
:30.0) Gecko/20100101 Firefox/30.0 | 309 /index.html?q=foo\0www.example.com\0Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv
:30.0) Gecko/20100101 Firefox/30.0 |
307 </pre> | 310 </pre> |
308 | 311 |
309 <p> | 312 <p> |
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).}} | 313 {{s111 Finally, generate the signature for this string by using the signature
algorithm SEC_OID_ISO_SHA_WITH_RSA_SIGNATURE (default when using OpenSSL).}} |
311 </p> | 314 </p> |
OLD | NEW |