OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 docDomain = docDomain.toUpperCase(); | 471 docDomain = docDomain.toUpperCase(); |
472 | 472 |
473 for (let domain in this.domains) | 473 for (let domain in this.domains) |
474 if (this.domains[domain] && domain != docDomain && (domain.length <= docDo
main.length || domain.indexOf("." + docDomain) != domain.length - docDomain.leng
th - 1)) | 474 if (this.domains[domain] && domain != docDomain && (domain.length <= docDo
main.length || domain.indexOf("." + docDomain) != domain.length - docDomain.leng
th - 1)) |
475 return false; | 475 return false; |
476 | 476 |
477 return true; | 477 return true; |
478 }, | 478 }, |
479 | 479 |
480 /** | 480 /** |
| 481 * Checks whether this filter is generic or specific |
| 482 * @return {Boolean} true if filter is generic, otherwise false |
| 483 */ |
| 484 isGeneric: function() /**Boolean*/ |
| 485 { |
| 486 return (!(this.sitekeys && this.sitekeys.length) && |
| 487 (!this.domains || this.domains[""])); |
| 488 }, |
| 489 |
| 490 /** |
481 * See Filter.serialize() | 491 * See Filter.serialize() |
482 */ | 492 */ |
483 serialize: function(buffer) | 493 serialize: function(buffer) |
484 { | 494 { |
485 if (this._disabled || this._hitCount || this._lastHit) | 495 if (this._disabled || this._hitCount || this._lastHit) |
486 { | 496 { |
487 Filter.prototype.serialize.call(this, buffer); | 497 Filter.prototype.serialize.call(this, buffer); |
488 if (this._disabled) | 498 if (this._disabled) |
489 buffer.push("disabled=true"); | 499 buffer.push("disabled=true"); |
490 if (this._hitCount) | 500 if (this._hitCount) |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 PING: 1, | 757 PING: 1, |
748 XMLHTTPREQUEST: 2048, | 758 XMLHTTPREQUEST: 2048, |
749 OBJECT_SUBREQUEST: 4096, | 759 OBJECT_SUBREQUEST: 4096, |
750 DTD: 1, | 760 DTD: 1, |
751 MEDIA: 16384, | 761 MEDIA: 16384, |
752 FONT: 32768, | 762 FONT: 32768, |
753 | 763 |
754 BACKGROUND: 4, // Backwards compat, same as IMAGE | 764 BACKGROUND: 4, // Backwards compat, same as IMAGE |
755 | 765 |
756 POPUP: 0x10000000, | 766 POPUP: 0x10000000, |
757 ELEMHIDE: 0x40000000 | 767 GENERICBLOCK: 0x20000000, |
| 768 ELEMHIDE: 0x40000000, |
| 769 GENERICHIDE: 0x80000000 |
758 }; | 770 }; |
759 | 771 |
760 // DOCUMENT, ELEMHIDE, POPUP options shouldn't be there by default | 772 // DOCUMENT, ELEMHIDE, POPUP, GENERICHIDE and GENERICBLOCK options shouldn't |
761 RegExpFilter.prototype.contentType &= ~(RegExpFilter.typeMap.DOCUMENT | RegExpFi
lter.typeMap.ELEMHIDE | RegExpFilter.typeMap.POPUP); | 773 // be there by default |
| 774 RegExpFilter.prototype.contentType &= ~(RegExpFilter.typeMap.DOCUMENT | |
| 775 RegExpFilter.typeMap.ELEMHIDE | |
| 776 RegExpFilter.typeMap.POPUP | |
| 777 RegExpFilter.typeMap.GENERICHIDE | |
| 778 RegExpFilter.typeMap.GENERICBLOCK); |
762 | 779 |
763 /** | 780 /** |
764 * Class for blocking filters | 781 * Class for blocking filters |
765 * @param {String} text see Filter() | 782 * @param {String} text see Filter() |
766 * @param {String} regexpSource see RegExpFilter() | 783 * @param {String} regexpSource see RegExpFilter() |
767 * @param {Number} contentType see RegExpFilter() | 784 * @param {Number} contentType see RegExpFilter() |
768 * @param {Boolean} matchCase see RegExpFilter() | 785 * @param {Boolean} matchCase see RegExpFilter() |
769 * @param {String} domains see RegExpFilter() | 786 * @param {String} domains see RegExpFilter() |
770 * @param {Boolean} thirdParty see RegExpFilter() | 787 * @param {Boolean} thirdParty see RegExpFilter() |
771 * @param {String} sitekeys see RegExpFilter() | 788 * @param {String} sitekeys see RegExpFilter() |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 // several times on Safari, due to WebKit bug 132872 | 1038 // several times on Safari, due to WebKit bug 132872 |
1022 let prop = Object.getOwnPropertyDescriptor(this, "regexpString"); | 1039 let prop = Object.getOwnPropertyDescriptor(this, "regexpString"); |
1023 if (prop) | 1040 if (prop) |
1024 return prop.value; | 1041 return prop.value; |
1025 | 1042 |
1026 let regexp = Filter.toRegExp(this.regexpSource); | 1043 let regexp = Filter.toRegExp(this.regexpSource); |
1027 Object.defineProperty(this, "regexpString", {value: regexp}); | 1044 Object.defineProperty(this, "regexpString", {value: regexp}); |
1028 return regexp; | 1045 return regexp; |
1029 } | 1046 } |
1030 }; | 1047 }; |
OLD | NEW |