Documentation/Source/eric6.WebBrowser.AdBlock.AdBlockRule.html

changeset 4918
71caf42a13d8
child 5606
da305d172769
equal deleted inserted replaced
4917:682750cc7bd5 4918:71caf42a13d8
1 <!DOCTYPE html>
2 <html><head>
3 <title>eric6.WebBrowser.AdBlock.AdBlockRule</title>
4 <meta charset="UTF-8">
5 <style>
6 body {
7 background: #EDECE6;
8 margin: 0em 1em 10em 1em;
9 color: black;
10 }
11
12 h1 { color: white; background: #85774A; }
13 h2 { color: white; background: #85774A; }
14 h3 { color: white; background: #9D936E; }
15 h4 { color: white; background: #9D936E; }
16
17 a { color: #BA6D36; }
18
19 </style>
20 </head>
21 <body><a NAME="top" ID="top"></a>
22 <h1>eric6.WebBrowser.AdBlock.AdBlockRule</h1>
23 <p>
24 Module implementing the AdBlock rule class.
25 </p>
26 <h3>Global Attributes</h3>
27 <table>
28 <tr><td>None</td></tr>
29 </table>
30 <h3>Classes</h3>
31 <table>
32 <tr>
33 <td><a href="#AdBlockRule">AdBlockRule</a></td>
34 <td>Class implementing the AdBlock rule.</td>
35 </tr>
36 </table>
37 <h3>Functions</h3>
38 <table>
39 <tr>
40 <td><a href="#toSecondLevelDomain">toSecondLevelDomain</a></td>
41 <td>Module function to get a second level domain from the given URL.</td>
42 </tr>
43 </table>
44 <hr /><hr />
45 <a NAME="AdBlockRule" ID="AdBlockRule"></a>
46 <h2>AdBlockRule</h2>
47 <p>
48 Class implementing the AdBlock rule.
49 </p>
50 <h3>Derived from</h3>
51 object
52 <h3>Class Attributes</h3>
53 <table>
54 <tr><td>None</td></tr>
55 </table>
56 <h3>Class Methods</h3>
57 <table>
58 <tr><td>None</td></tr>
59 </table>
60 <h3>Methods</h3>
61 <table>
62 <tr>
63 <td><a href="#AdBlockRule.__init__">AdBlockRule</a></td>
64 <td>Constructor</td>
65 </tr><tr>
66 <td><a href="#AdBlockRule.__convertPatternToRegExp">__convertPatternToRegExp</a></td>
67 <td>Private method to convert a wildcard pattern to a regular expression.</td>
68 </tr><tr>
69 <td><a href="#AdBlockRule.__parseDomains">__parseDomains</a></td>
70 <td>Private method to parse a string with a domain list.</td>
71 </tr><tr>
72 <td><a href="#AdBlockRule.__parseFilter">__parseFilter</a></td>
73 <td>Private method to parse the filter pattern.</td>
74 </tr><tr>
75 <td><a href="#AdBlockRule.__stringMatch">__stringMatch</a></td>
76 <td>Private method to match a domain string.</td>
77 </tr><tr>
78 <td><a href="#AdBlockRule.cssSelector">cssSelector</a></td>
79 <td>Public method to get the CSS selector of the rule.</td>
80 </tr><tr>
81 <td><a href="#AdBlockRule.filter">filter</a></td>
82 <td>Public method to get the rule filter string.</td>
83 </tr><tr>
84 <td><a href="#AdBlockRule.isCSSRule">isCSSRule</a></td>
85 <td>Public method to check, if the rule is a CSS rule.</td>
86 </tr><tr>
87 <td><a href="#AdBlockRule.isComment">isComment</a></td>
88 <td>Public method to check, if this is a comment.</td>
89 </tr><tr>
90 <td><a href="#AdBlockRule.isDocument">isDocument</a></td>
91 <td>Public method to check, if this is a document rule.</td>
92 </tr><tr>
93 <td><a href="#AdBlockRule.isDomainRestricted">isDomainRestricted</a></td>
94 <td>Public method to check, if this rule is restricted by domain.</td>
95 </tr><tr>
96 <td><a href="#AdBlockRule.isElementHiding">isElementHiding</a></td>
97 <td>Public method to check, if this is an element hiding rule.</td>
98 </tr><tr>
99 <td><a href="#AdBlockRule.isEnabled">isEnabled</a></td>
100 <td>Public method to check, if the rule is enabled.</td>
101 </tr><tr>
102 <td><a href="#AdBlockRule.isException">isException</a></td>
103 <td>Public method to check, if the rule defines an exception.</td>
104 </tr><tr>
105 <td><a href="#AdBlockRule.isHeader">isHeader</a></td>
106 <td>Public method to check, if this is a header.</td>
107 </tr><tr>
108 <td><a href="#AdBlockRule.isInternalDisabled">isInternalDisabled</a></td>
109 <td>Public method to check, if this rule was disabled internally.</td>
110 </tr><tr>
111 <td><a href="#AdBlockRule.isSlow">isSlow</a></td>
112 <td>Public method to check, if this is a slow rule.</td>
113 </tr><tr>
114 <td><a href="#AdBlockRule.matchDomain">matchDomain</a></td>
115 <td>Public method to match a domain.</td>
116 </tr><tr>
117 <td><a href="#AdBlockRule.matchImage">matchImage</a></td>
118 <td>Public slot to match an Image rule.</td>
119 </tr><tr>
120 <td><a href="#AdBlockRule.matchObject">matchObject</a></td>
121 <td>Public slot to match an object rule.</td>
122 </tr><tr>
123 <td><a href="#AdBlockRule.matchObjectSubrequest">matchObjectSubrequest</a></td>
124 <td>Public slot to match an Object Subrequest rule.</td>
125 </tr><tr>
126 <td><a href="#AdBlockRule.matchScript">matchScript</a></td>
127 <td>Public slot to match a Script rule.</td>
128 </tr><tr>
129 <td><a href="#AdBlockRule.matchStyleSheet">matchStyleSheet</a></td>
130 <td>Public slot to match a StyleSheet rule.</td>
131 </tr><tr>
132 <td><a href="#AdBlockRule.matchSubdocument">matchSubdocument</a></td>
133 <td>Public slot to match a sub-document rule.</td>
134 </tr><tr>
135 <td><a href="#AdBlockRule.matchThirdParty">matchThirdParty</a></td>
136 <td>Public slot to match a third-party rule.</td>
137 </tr><tr>
138 <td><a href="#AdBlockRule.matchXmlHttpRequest">matchXmlHttpRequest</a></td>
139 <td>Public slot to match a XmlHttpRequest rule.</td>
140 </tr><tr>
141 <td><a href="#AdBlockRule.networkMatch">networkMatch</a></td>
142 <td>Public method to check the rule for a match.</td>
143 </tr><tr>
144 <td><a href="#AdBlockRule.setEnabled">setEnabled</a></td>
145 <td>Public method to set the rule's enabled state.</td>
146 </tr><tr>
147 <td><a href="#AdBlockRule.setException">setException</a></td>
148 <td>Public method to set the rule's exception flag.</td>
149 </tr><tr>
150 <td><a href="#AdBlockRule.setFilter">setFilter</a></td>
151 <td>Public method to set the rule filter string.</td>
152 </tr><tr>
153 <td><a href="#AdBlockRule.subscription">subscription</a></td>
154 <td>Public method to get the subscription this rule belongs to.</td>
155 </tr><tr>
156 <td><a href="#AdBlockRule.urlMatch">urlMatch</a></td>
157 <td>Public method to check an URL against the rule.</td>
158 </tr>
159 </table>
160 <h3>Static Methods</h3>
161 <table>
162 <tr><td>None</td></tr>
163 </table>
164 <a NAME="AdBlockRule.__init__" ID="AdBlockRule.__init__"></a>
165 <h4>AdBlockRule (Constructor)</h4>
166 <b>AdBlockRule</b>(<i>filter="", subscription=None</i>)
167 <p>
168 Constructor
169 </p><dl>
170 <dt><i>filter</i></dt>
171 <dd>
172 filter string of the rule (string)
173 </dd><dt><i>subscription</i></dt>
174 <dd>
175 reference to the subscription object
176 (AdBlockSubscription)
177 </dd>
178 </dl><a NAME="AdBlockRule.__convertPatternToRegExp" ID="AdBlockRule.__convertPatternToRegExp"></a>
179 <h4>AdBlockRule.__convertPatternToRegExp</h4>
180 <b>__convertPatternToRegExp</b>(<i>wildcardPattern</i>)
181 <p>
182 Private method to convert a wildcard pattern to a regular expression.
183 </p><dl>
184 <dt><i>wildcardPattern</i></dt>
185 <dd>
186 string containing the wildcard pattern (string)
187 </dd>
188 </dl><dl>
189 <dt>Returns:</dt>
190 <dd>
191 string containing a regular expression (string)
192 </dd>
193 </dl><a NAME="AdBlockRule.__parseDomains" ID="AdBlockRule.__parseDomains"></a>
194 <h4>AdBlockRule.__parseDomains</h4>
195 <b>__parseDomains</b>(<i>domains, separator</i>)
196 <p>
197 Private method to parse a string with a domain list.
198 </p><dl>
199 <dt><i>domains</i></dt>
200 <dd>
201 list of domains (string)
202 </dd><dt><i>separator</i></dt>
203 <dd>
204 separator character used by the list (string)
205 </dd>
206 </dl><a NAME="AdBlockRule.__parseFilter" ID="AdBlockRule.__parseFilter"></a>
207 <h4>AdBlockRule.__parseFilter</h4>
208 <b>__parseFilter</b>(<i></i>)
209 <p>
210 Private method to parse the filter pattern.
211 </p><a NAME="AdBlockRule.__stringMatch" ID="AdBlockRule.__stringMatch"></a>
212 <h4>AdBlockRule.__stringMatch</h4>
213 <b>__stringMatch</b>(<i>domain, encodedUrl</i>)
214 <p>
215 Private method to match a domain string.
216 </p><dl>
217 <dt><i>domain</i> (str)</dt>
218 <dd>
219 domain to match
220 </dd><dt><i>encodedUrl</i> (str)</dt>
221 <dd>
222 URL in encoded form
223 </dd>
224 </dl><dl>
225 <dt>Returns:</dt>
226 <dd>
227 flag indicating a match
228 </dd>
229 </dl><dl>
230 <dt>Return Type:</dt>
231 <dd>
232 bool
233 </dd>
234 </dl><a NAME="AdBlockRule.cssSelector" ID="AdBlockRule.cssSelector"></a>
235 <h4>AdBlockRule.cssSelector</h4>
236 <b>cssSelector</b>(<i></i>)
237 <p>
238 Public method to get the CSS selector of the rule.
239 </p><dl>
240 <dt>Returns:</dt>
241 <dd>
242 CSS selector (string)
243 </dd>
244 </dl><a NAME="AdBlockRule.filter" ID="AdBlockRule.filter"></a>
245 <h4>AdBlockRule.filter</h4>
246 <b>filter</b>(<i></i>)
247 <p>
248 Public method to get the rule filter string.
249 </p><dl>
250 <dt>Returns:</dt>
251 <dd>
252 rule filter string (string)
253 </dd>
254 </dl><a NAME="AdBlockRule.isCSSRule" ID="AdBlockRule.isCSSRule"></a>
255 <h4>AdBlockRule.isCSSRule</h4>
256 <b>isCSSRule</b>(<i></i>)
257 <p>
258 Public method to check, if the rule is a CSS rule.
259 </p><dl>
260 <dt>Returns:</dt>
261 <dd>
262 flag indicating a CSS rule (boolean)
263 </dd>
264 </dl><a NAME="AdBlockRule.isComment" ID="AdBlockRule.isComment"></a>
265 <h4>AdBlockRule.isComment</h4>
266 <b>isComment</b>(<i></i>)
267 <p>
268 Public method to check, if this is a comment.
269 </p><dl>
270 <dt>Returns:</dt>
271 <dd>
272 flag indicating a comment (boolean)
273 </dd>
274 </dl><a NAME="AdBlockRule.isDocument" ID="AdBlockRule.isDocument"></a>
275 <h4>AdBlockRule.isDocument</h4>
276 <b>isDocument</b>(<i></i>)
277 <p>
278 Public method to check, if this is a document rule.
279 </p><dl>
280 <dt>Returns:</dt>
281 <dd>
282 flag indicating a document rule (boolean)
283 </dd>
284 </dl><a NAME="AdBlockRule.isDomainRestricted" ID="AdBlockRule.isDomainRestricted"></a>
285 <h4>AdBlockRule.isDomainRestricted</h4>
286 <b>isDomainRestricted</b>(<i></i>)
287 <p>
288 Public method to check, if this rule is restricted by domain.
289 </p><dl>
290 <dt>Returns:</dt>
291 <dd>
292 flag indicating a domain restriction (boolean)
293 </dd>
294 </dl><a NAME="AdBlockRule.isElementHiding" ID="AdBlockRule.isElementHiding"></a>
295 <h4>AdBlockRule.isElementHiding</h4>
296 <b>isElementHiding</b>(<i></i>)
297 <p>
298 Public method to check, if this is an element hiding rule.
299 </p><dl>
300 <dt>Returns:</dt>
301 <dd>
302 flag indicating an element hiding rule (boolean)
303 </dd>
304 </dl><a NAME="AdBlockRule.isEnabled" ID="AdBlockRule.isEnabled"></a>
305 <h4>AdBlockRule.isEnabled</h4>
306 <b>isEnabled</b>(<i></i>)
307 <p>
308 Public method to check, if the rule is enabled.
309 </p><dl>
310 <dt>Returns:</dt>
311 <dd>
312 flag indicating enabled state (boolean)
313 </dd>
314 </dl><a NAME="AdBlockRule.isException" ID="AdBlockRule.isException"></a>
315 <h4>AdBlockRule.isException</h4>
316 <b>isException</b>(<i></i>)
317 <p>
318 Public method to check, if the rule defines an exception.
319 </p><dl>
320 <dt>Returns:</dt>
321 <dd>
322 flag indicating an exception (boolean)
323 </dd>
324 </dl><a NAME="AdBlockRule.isHeader" ID="AdBlockRule.isHeader"></a>
325 <h4>AdBlockRule.isHeader</h4>
326 <b>isHeader</b>(<i></i>)
327 <p>
328 Public method to check, if this is a header.
329 </p><dl>
330 <dt>Returns:</dt>
331 <dd>
332 flag indicating a header (boolean)
333 </dd>
334 </dl><a NAME="AdBlockRule.isInternalDisabled" ID="AdBlockRule.isInternalDisabled"></a>
335 <h4>AdBlockRule.isInternalDisabled</h4>
336 <b>isInternalDisabled</b>(<i></i>)
337 <p>
338 Public method to check, if this rule was disabled internally.
339 </p><dl>
340 <dt>Returns:</dt>
341 <dd>
342 flag indicating an internally disabled rule (boolean)
343 </dd>
344 </dl><a NAME="AdBlockRule.isSlow" ID="AdBlockRule.isSlow"></a>
345 <h4>AdBlockRule.isSlow</h4>
346 <b>isSlow</b>(<i></i>)
347 <p>
348 Public method to check, if this is a slow rule.
349 </p><dl>
350 <dt>Returns:</dt>
351 <dd>
352 flag indicating a slow rule (boolean)
353 </dd>
354 </dl><a NAME="AdBlockRule.matchDomain" ID="AdBlockRule.matchDomain"></a>
355 <h4>AdBlockRule.matchDomain</h4>
356 <b>matchDomain</b>(<i>domain</i>)
357 <p>
358 Public method to match a domain.
359 </p><dl>
360 <dt><i>domain</i></dt>
361 <dd>
362 domain name to check (string)
363 </dd>
364 </dl><dl>
365 <dt>Returns:</dt>
366 <dd>
367 flag indicating a match (boolean)
368 </dd>
369 </dl><a NAME="AdBlockRule.matchImage" ID="AdBlockRule.matchImage"></a>
370 <h4>AdBlockRule.matchImage</h4>
371 <b>matchImage</b>(<i>req</i>)
372 <p>
373 Public slot to match an Image rule.
374 </p><dl>
375 <dt><i>req</i></dt>
376 <dd>
377 request object to check (QWebEngineUrlRequestInfo)
378 </dd>
379 </dl><dl>
380 <dt>Returns:</dt>
381 <dd>
382 flag indicating a match (boolean)
383 </dd>
384 </dl><a NAME="AdBlockRule.matchObject" ID="AdBlockRule.matchObject"></a>
385 <h4>AdBlockRule.matchObject</h4>
386 <b>matchObject</b>(<i>req</i>)
387 <p>
388 Public slot to match an object rule.
389 </p><dl>
390 <dt><i>req</i></dt>
391 <dd>
392 request object to check (QWebEngineUrlRequestInfo)
393 </dd>
394 </dl><dl>
395 <dt>Returns:</dt>
396 <dd>
397 flag indicating a match (boolean)
398 </dd>
399 </dl><a NAME="AdBlockRule.matchObjectSubrequest" ID="AdBlockRule.matchObjectSubrequest"></a>
400 <h4>AdBlockRule.matchObjectSubrequest</h4>
401 <b>matchObjectSubrequest</b>(<i>req</i>)
402 <p>
403 Public slot to match an Object Subrequest rule.
404 </p><dl>
405 <dt><i>req</i></dt>
406 <dd>
407 request object to check (QWebEngineUrlRequestInfo)
408 </dd>
409 </dl><dl>
410 <dt>Returns:</dt>
411 <dd>
412 flag indicating a match (boolean)
413 </dd>
414 </dl><a NAME="AdBlockRule.matchScript" ID="AdBlockRule.matchScript"></a>
415 <h4>AdBlockRule.matchScript</h4>
416 <b>matchScript</b>(<i>req</i>)
417 <p>
418 Public slot to match a Script rule.
419 </p><dl>
420 <dt><i>req</i></dt>
421 <dd>
422 request object to check (QWebEngineUrlRequestInfo)
423 </dd>
424 </dl><dl>
425 <dt>Returns:</dt>
426 <dd>
427 flag indicating a match (boolean)
428 </dd>
429 </dl><a NAME="AdBlockRule.matchStyleSheet" ID="AdBlockRule.matchStyleSheet"></a>
430 <h4>AdBlockRule.matchStyleSheet</h4>
431 <b>matchStyleSheet</b>(<i>req</i>)
432 <p>
433 Public slot to match a StyleSheet rule.
434 </p><dl>
435 <dt><i>req</i></dt>
436 <dd>
437 request object to check (QWebEngineUrlRequestInfo)
438 </dd>
439 </dl><dl>
440 <dt>Returns:</dt>
441 <dd>
442 flag indicating a match (boolean)
443 </dd>
444 </dl><a NAME="AdBlockRule.matchSubdocument" ID="AdBlockRule.matchSubdocument"></a>
445 <h4>AdBlockRule.matchSubdocument</h4>
446 <b>matchSubdocument</b>(<i>req</i>)
447 <p>
448 Public slot to match a sub-document rule.
449 </p><dl>
450 <dt><i>req</i></dt>
451 <dd>
452 request object to check (QWebEngineUrlRequestInfo)
453 </dd>
454 </dl><dl>
455 <dt>Returns:</dt>
456 <dd>
457 flag indicating a match (boolean)
458 </dd>
459 </dl><a NAME="AdBlockRule.matchThirdParty" ID="AdBlockRule.matchThirdParty"></a>
460 <h4>AdBlockRule.matchThirdParty</h4>
461 <b>matchThirdParty</b>(<i>req</i>)
462 <p>
463 Public slot to match a third-party rule.
464 </p><dl>
465 <dt><i>req</i></dt>
466 <dd>
467 request object to check (QWebEngineUrlRequestInfo)
468 </dd>
469 </dl><dl>
470 <dt>Returns:</dt>
471 <dd>
472 flag indicating a match (boolean)
473 </dd>
474 </dl><a NAME="AdBlockRule.matchXmlHttpRequest" ID="AdBlockRule.matchXmlHttpRequest"></a>
475 <h4>AdBlockRule.matchXmlHttpRequest</h4>
476 <b>matchXmlHttpRequest</b>(<i>req</i>)
477 <p>
478 Public slot to match a XmlHttpRequest rule.
479 </p><dl>
480 <dt><i>req</i></dt>
481 <dd>
482 request object to check (QWebEngineUrlRequestInfo)
483 </dd>
484 </dl><dl>
485 <dt>Returns:</dt>
486 <dd>
487 flag indicating a match (boolean)
488 </dd>
489 </dl><a NAME="AdBlockRule.networkMatch" ID="AdBlockRule.networkMatch"></a>
490 <h4>AdBlockRule.networkMatch</h4>
491 <b>networkMatch</b>(<i>request, domain, encodedUrl</i>)
492 <p>
493 Public method to check the rule for a match.
494 </p><dl>
495 <dt><i>request</i> (QWebEngineUrlRequestInfo)</dt>
496 <dd>
497 reference to the network request
498 </dd><dt><i>domain</i> (str)</dt>
499 <dd>
500 domain name
501 </dd><dt><i>encodedUrl</i> (str)</dt>
502 <dd>
503 string encoded URL to be checked
504 </dd>
505 </dl><dl>
506 <dt>Returns:</dt>
507 <dd>
508 flag indicating a match
509 </dd>
510 </dl><dl>
511 <dt>Return Type:</dt>
512 <dd>
513 bool
514 </dd>
515 </dl><a NAME="AdBlockRule.setEnabled" ID="AdBlockRule.setEnabled"></a>
516 <h4>AdBlockRule.setEnabled</h4>
517 <b>setEnabled</b>(<i>enabled</i>)
518 <p>
519 Public method to set the rule's enabled state.
520 </p><dl>
521 <dt><i>enabled</i></dt>
522 <dd>
523 flag indicating the new enabled state (boolean)
524 </dd>
525 </dl><a NAME="AdBlockRule.setException" ID="AdBlockRule.setException"></a>
526 <h4>AdBlockRule.setException</h4>
527 <b>setException</b>(<i>exception</i>)
528 <p>
529 Public method to set the rule's exception flag.
530 </p><dl>
531 <dt><i>exception</i></dt>
532 <dd>
533 flag indicating an exception rule (boolean)
534 </dd>
535 </dl><a NAME="AdBlockRule.setFilter" ID="AdBlockRule.setFilter"></a>
536 <h4>AdBlockRule.setFilter</h4>
537 <b>setFilter</b>(<i>filter</i>)
538 <p>
539 Public method to set the rule filter string.
540 </p><dl>
541 <dt><i>filter</i></dt>
542 <dd>
543 rule filter string (string)
544 </dd>
545 </dl><a NAME="AdBlockRule.subscription" ID="AdBlockRule.subscription"></a>
546 <h4>AdBlockRule.subscription</h4>
547 <b>subscription</b>(<i></i>)
548 <p>
549 Public method to get the subscription this rule belongs to.
550 </p><dl>
551 <dt>Returns:</dt>
552 <dd>
553 subscription of the rule (AdBlockSubscription)
554 </dd>
555 </dl><a NAME="AdBlockRule.urlMatch" ID="AdBlockRule.urlMatch"></a>
556 <h4>AdBlockRule.urlMatch</h4>
557 <b>urlMatch</b>(<i>url</i>)
558 <p>
559 Public method to check an URL against the rule.
560 </p><dl>
561 <dt><i>url</i></dt>
562 <dd>
563 URL to check (QUrl)
564 </dd>
565 </dl><dl>
566 <dt>Returns:</dt>
567 <dd>
568 flag indicating a match (boolean)
569 </dd>
570 </dl>
571 <div align="right"><a href="#top">Up</a></div>
572 <hr /><hr />
573 <a NAME="toSecondLevelDomain" ID="toSecondLevelDomain"></a>
574 <h2>toSecondLevelDomain</h2>
575 <b>toSecondLevelDomain</b>(<i>url</i>)
576 <p>
577 Module function to get a second level domain from the given URL.
578 </p><dl>
579 <dt><i>url</i></dt>
580 <dd>
581 URL to extract domain from (QUrl)
582 </dd>
583 </dl><dl>
584 <dt>Returns:</dt>
585 <dd>
586 name of second level domain (string)
587 </dd>
588 </dl>
589 <div align="right"><a href="#top">Up</a></div>
590 <hr />
591 </body></html>

eric ide

mercurial