Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: pages/filters.html

Issue 29482703: Issue 5353 - Add advanced element hiding filters documentation (Closed) Base URL: https://hg.adblockplus.org/web.adblockplus.org/
Patch Set: Updated. Created July 12, 2017, 10:12 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« pages/filter-cheatsheet.html ('K') | « pages/filter-cheatsheet.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 <h3 id="elemhide_attributes">{{s93 Attribute selectors}}</h3> 226 <h3 id="elemhide_attributes">{{s93 Attribute selectors}}</h3>
227 227
228 <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 <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>
229 229
230 <h3 id="elemhide_css">{{s95 Advanced selectors}}</h3> 230 <h3 id="elemhide_css">{{s95 Advanced selectors}}</h3>
231 231
232 <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 <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>
233 233
234 <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 <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>
235 235
236 <h3 id="elemhide-emulation">{{elemhide-emulation-title Advanced pseudo-selectors }}</h3>
kzar 2017/07/13 11:37:18 After discussing in IRC I think "Extended CSS Sele
hub 2017/07/13 20:17:34 Acknowledged.
237
238 <p>
239 {{elemhide-emulation-explanation-p1 Sometime CSS selectors aren't enough to ch ose items. In certain circumstances examining the content of an element is requi red, and this is why we have added the advanced pseudo-selector <code><fix>:-abp -has()</fix></code> and <code><fix>:-abp-properties()</fix></code>. The filter r ule <code><fix>example.com#?#selector</fix></code> will hide elements matching t he selector.}}
kzar 2017/07/13 11:37:18 How about this for the first two paragraphs? "Som
hub 2017/07/13 20:17:34 Acknowledged.
240 </p>
241 <p>
242 {{elemhide-emulation-explanation-p2 In order to minimise the performance impac t, it is important to restrict with a proper CSS selector the number of elements these pseudo-selectors apply to. These filters only exist as <a href="#generic- specific">specific filters</a>, a domain is mandatory.}}
243 </p>
244 <p>{{elemhide-emulation-explanation-p3 <em>Note</em>: You can also use these fil ter rules for a regular CSS selector. They might work better in certain situatio ns.}}
kzar 2017/07/13 11:37:18 I think we should remove this note, it relates to
hub 2017/07/13 20:17:34 Done.
245 </p>
246 <h4>{{abp-properties-title :-abp-properties()}}</h4>
247 <p>
248 {{abp-properties-explanation-p1 <code><fix>:-abp-properties(properties)</fix>< /code> will select elements based on properties of their stylesheet. For example <code><fix>:-abp-properties(width:300px;height:250px;)</fix></code> will select elements that have <code><fix>width</fix></code> and <code><fix>height</fix></c ode> set to the specified values <code><fix>300px</fix></code> and <code><fix>25 0px</fix></code> respectively.}}
kzar 2017/07/13 11:37:18 I guess the explanation of the example here is not
kzar 2017/07/13 11:37:18 Maybe mention how the properties are matched case-
hub 2017/07/13 20:17:34 Done.
249 </p>
250 <p>
251 {{abp-properties-explanation-p2 <em>Note</em>: The <a href="https://adblockplu s.org/development-builds/new-css-property-filter-syntax">older syntax</a> for th e CSS property filters is deprecated and will be automatically converted to the new format&nbsp;. The syntax to select the style properties remain the same. For example, <code><fix>[-abp-properties='width:300px;height:250px;']</fix></code> will be converted to <code><fix>:-abp-properties(width:300px;height:250px;)</fix ></code>.}}
252 </p>
253 <h4>{{abp-has-title :-abp-has()}}</h4>
254 <p>
255 {{abp-has-explanation-p1 <code><fix>:-abp-has(selector)</fix></code> will sele ct elements based on their content. For example <code><fix>:-abp-has(> div > a.a dvertiser)</fix></code> will select elements that contain as a direct descendant a <code><fix>&lt;div&gt;</fix></code> that contains an <code><fix>&lt;a&gt;</fi x></code> with the class <code><fix>advertiser</fix></code>. The inner selector can be relative to the element scope, and can use any of the pseudo-selectors, i ncluding <code><fix>:-abp-has()</fix></code> and will determine whether the sele ction occur.}}
256 </p>
257
236 <h3 id="elemhide_exceptions">{{s99 Exception rules}}</h3> 258 <h3 id="elemhide_exceptions">{{s99 Exception rules}}</h3>
237 259
238 <p> 260 <p>
239 {{s100 Exception rules can disable existing rules on particular domains.}} {{s 101 These are mostly 261 {{s100 Exception rules can disable existing rules on particular domains.}} {{s 101 These are mostly
240 useful to filter subscription authors who are extending another filter subscri ption that they 262 useful to filter subscription authors who are extending another filter subscri ption that they
241 cannot change.}} {{s102 For example, the rule <code><fix>##div.textad</fix></c ode> can be 263 cannot change.}} {{s102 For example, the rule <code><fix>##div.textad</fix></c ode> can be
242 disabled on <code><fix>example.com</fix></code> using the exception rule 264 disabled on <code><fix>example.com</fix></code> using the exception rule
243 <code><fix>example.com#@#div.textad</fix></code>.}} {{s103 The combination of these two 265 <code><fix>example.com#@#div.textad</fix></code>.}} {{s103 The combination of these two
244 rules has exactly the same effect as the single rule 266 rules has exactly the same effect as the single rule
245 <code><fix>~example.com##div.textad</fix></code>.}} {{s104 It is recommended t hat you use 267 <code><fix>~example.com##div.textad</fix></code>.}} {{s104 It is recommended t hat you use
246 exception rules only when you cannot change an overly general element hiding r ule, in all the 268 exception rules only when you cannot change an overly general element hiding r ule, in all the
247 other cases limiting this rule to the necessary domains is preferable.}} 269 other cases limiting this rule to the necessary domains is preferable.}}
270 {{exception-rules-p6 These exceptions will be applied to <a href="#elemhide-em ulation">advanced pseudo-selector rules</a> as well.}}
248 </p> 271 </p>
249 272
250 <h3 id="elemhide_simplified">{{s105 Simplified element hiding syntax}}</h3> 273 <h3 id="elemhide_simplified">{{s105 Simplified element hiding syntax}}</h3>
251 274
252 <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> 275 <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>
253 276
254 <h3 id="generic-specific">{{generic-specific-title Generic / Specific filters} }</h3> 277 <h3 id="generic-specific">{{generic-specific-title Generic / Specific filters} }</h3>
255 278
256 <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> 279 <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>
257 <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> 280 <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>
(...skipping 13 matching lines...) Expand all
271 {{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:}} 294 {{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:}}
272 </p> 295 </p>
273 296
274 <pre> 297 <pre>
275 /index.html?q=foo\0www.example.com\0Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv :30.0) Gecko/20100101 Firefox/30.0 298 /index.html?q=foo\0www.example.com\0Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv :30.0) Gecko/20100101 Firefox/30.0
276 </pre> 299 </pre>
277 300
278 <p> 301 <p>
279 {{s111 Finally, generate the signature for this string by using the signature algorithm SEC_OID_ISO_SHA_WITH_RSA_SIGNATURE (default when using OpenSSL).}} 302 {{s111 Finally, generate the signature for this string by using the signature algorithm SEC_OID_ISO_SHA_WITH_RSA_SIGNATURE (default when using OpenSSL).}}
280 </p> 303 </p>
OLDNEW
« pages/filter-cheatsheet.html ('K') | « pages/filter-cheatsheet.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld