OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 domainSeparator: null, | 296 domainSeparator: null, |
297 | 297 |
298 /** | 298 /** |
299 * Determines whether the trailing dot in domain names isn't important and | 299 * Determines whether the trailing dot in domain names isn't important and |
300 * should be ignored, must be overridden by subclasses. | 300 * should be ignored, must be overridden by subclasses. |
301 * @type Boolean | 301 * @type Boolean |
302 */ | 302 */ |
303 ignoreTrailingDot: true, | 303 ignoreTrailingDot: true, |
304 | 304 |
305 /** | 305 /** |
| 306 * Determines whether domainSource is already upper-case, |
| 307 * can be overridden by subclasses. |
| 308 * @type Boolean |
| 309 */ |
| 310 domainSourceIsUpperCase: false, |
| 311 |
| 312 /** |
306 * Map containing domains that this filter should match on/not match on or nul
l if the filter should match on all domains | 313 * Map containing domains that this filter should match on/not match on or nul
l if the filter should match on all domains |
307 * @type Object | 314 * @type Object |
308 */ | 315 */ |
309 get domains() | 316 get domains() |
310 { | 317 { |
311 let domains = null; | 318 let domains = null; |
312 | 319 |
313 if (this.domainSource) | 320 if (this.domainSource) |
314 { | 321 { |
315 let list = this.domainSource.split(this.domainSeparator); | 322 let source = this.domainSource; |
| 323 if (!this.domainSourceIsUpperCase) { |
| 324 // RegExpFilter already have uppercase domains |
| 325 source = source.toUpperCase(); |
| 326 } |
| 327 let list = source.split(this.domainSeparator); |
316 if (list.length == 1 && list[0][0] != "~") | 328 if (list.length == 1 && list[0][0] != "~") |
317 { | 329 { |
318 // Fast track for the common one-domain scenario | 330 // Fast track for the common one-domain scenario |
319 domains = {__proto__: null, "": false}; | 331 domains = {__proto__: null, "": false}; |
320 if (this.ignoreTrailingDot) | 332 if (this.ignoreTrailingDot) |
321 list[0] = list[0].replace(/\.+$/, ""); | 333 list[0] = list[0].replace(/\.+$/, ""); |
322 domains[list[0]] = true; | 334 domains[list[0]] = true; |
323 } | 335 } |
324 else | 336 else |
325 { | 337 { |
(...skipping 19 matching lines...) Expand all Loading... |
345 } | 357 } |
346 | 358 |
347 if (!domains) | 359 if (!domains) |
348 domains = {__proto__: null}; | 360 domains = {__proto__: null}; |
349 | 361 |
350 domains[domain] = include; | 362 domains[domain] = include; |
351 } | 363 } |
352 domains[""] = !hasIncludes; | 364 domains[""] = !hasIncludes; |
353 } | 365 } |
354 | 366 |
355 delete this.domainSource; | 367 this.domainSource = null; |
356 } | 368 } |
357 | 369 |
358 this.__defineGetter__("domains", function() domains); | 370 this.__defineGetter__("domains", function() domains); |
359 return this.domains; | 371 return this.domains; |
360 }, | 372 }, |
361 | 373 |
362 /** | 374 /** |
363 * Checks whether this filter is active on a domain. | 375 * Checks whether this filter is active on a domain. |
364 */ | 376 */ |
365 isActiveOnDomain: function(/**String*/ docDomain) /**Boolean*/ | 377 isActiveOnDomain: function(/**String*/ docDomain) /**Boolean*/ |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 this.regexpSource = regexpSource; | 472 this.regexpSource = regexpSource; |
461 } | 473 } |
462 } | 474 } |
463 exports.RegExpFilter = RegExpFilter; | 475 exports.RegExpFilter = RegExpFilter; |
464 | 476 |
465 RegExpFilter.prototype = | 477 RegExpFilter.prototype = |
466 { | 478 { |
467 __proto__: ActiveFilter.prototype, | 479 __proto__: ActiveFilter.prototype, |
468 | 480 |
469 /** | 481 /** |
| 482 * @see ActiveFilter.domainSourceIsUpperCase |
| 483 */ |
| 484 domainSourceIsUpperCase: true, |
| 485 |
| 486 /** |
470 * Number of filters contained, will always be 1 (required to optimize Matcher
). | 487 * Number of filters contained, will always be 1 (required to optimize Matcher
). |
471 * @type Integer | 488 * @type Integer |
472 */ | 489 */ |
473 length: 1, | 490 length: 1, |
474 | 491 |
475 /** | 492 /** |
476 * @see ActiveFilter.domainSeparator | 493 * @see ActiveFilter.domainSeparator |
477 */ | 494 */ |
478 domainSeparator: "|", | 495 domainSeparator: "|", |
479 | 496 |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 /** | 755 /** |
739 * Base class for element hiding filters | 756 * Base class for element hiding filters |
740 * @param {String} text see Filter() | 757 * @param {String} text see Filter() |
741 * @param {String} domains (optional) Host names or domains the filter should
be restricted to | 758 * @param {String} domains (optional) Host names or domains the filter should
be restricted to |
742 * @param {String} selector CSS selector for the HTML elements that should be
hidden | 759 * @param {String} selector CSS selector for the HTML elements that should be
hidden |
743 * @constructor | 760 * @constructor |
744 * @augments ActiveFilter | 761 * @augments ActiveFilter |
745 */ | 762 */ |
746 function ElemHideBase(text, domains, selector) | 763 function ElemHideBase(text, domains, selector) |
747 { | 764 { |
748 ActiveFilter.call(this, text, domains ? domains.toUpperCase() : null); | 765 ActiveFilter.call(this, text, domains || null); |
749 | 766 |
750 if (domains) | 767 if (domains) |
751 this.selectorDomain = domains.replace(/,~[^,]+/g, "").replace(/^~[^,]+,?/, "
").toLowerCase(); | 768 this.selectorDomain = domains.replace(/,~[^,]+/g, "").replace(/^~[^,]+,?/, "
").toLowerCase(); |
752 this.selector = selector; | 769 this.selector = selector; |
753 } | 770 } |
754 exports.ElemHideBase = ElemHideBase; | 771 exports.ElemHideBase = ElemHideBase; |
755 | 772 |
756 ElemHideBase.prototype = | 773 ElemHideBase.prototype = |
757 { | 774 { |
758 __proto__: ActiveFilter.prototype, | 775 __proto__: ActiveFilter.prototype, |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 function ElemHideException(text, domains, selector) | 882 function ElemHideException(text, domains, selector) |
866 { | 883 { |
867 ElemHideBase.call(this, text, domains, selector); | 884 ElemHideBase.call(this, text, domains, selector); |
868 } | 885 } |
869 exports.ElemHideException = ElemHideException; | 886 exports.ElemHideException = ElemHideException; |
870 | 887 |
871 ElemHideException.prototype = | 888 ElemHideException.prototype = |
872 { | 889 { |
873 __proto__: ElemHideBase.prototype | 890 __proto__: ElemHideBase.prototype |
874 }; | 891 }; |
OLD | NEW |