| 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-present eyeo GmbH | 3  * Copyright (C) 2006-present 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 233   return beforeOptions + "$" + options.join(); | 233   return beforeOptions + "$" + options.join(); | 
| 234 }; | 234 }; | 
| 235 | 235 | 
| 236 /** | 236 /** | 
| 237  * @see filterToRegExp | 237  * @see filterToRegExp | 
| 238  */ | 238  */ | 
| 239 Filter.toRegExp = filterToRegExp; | 239 Filter.toRegExp = filterToRegExp; | 
| 240 | 240 | 
| 241 /** | 241 /** | 
| 242  * Class for invalid filters | 242  * Class for invalid filters | 
| 243  * @param {string} text see Filter() | 243  * @param {string} text see {@link Filter Filter()} | 
| 244  * @param {string} reason Reason why this filter is invalid | 244  * @param {string} reason Reason why this filter is invalid | 
| 245  * @constructor | 245  * @constructor | 
| 246  * @augments Filter | 246  * @augments Filter | 
| 247  */ | 247  */ | 
| 248 function InvalidFilter(text, reason) | 248 function InvalidFilter(text, reason) | 
| 249 { | 249 { | 
| 250   Filter.call(this, text); | 250   Filter.call(this, text); | 
| 251 | 251 | 
| 252   this.reason = reason; | 252   this.reason = reason; | 
| 253 } | 253 } | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 264 | 264 | 
| 265   /** | 265   /** | 
| 266    * See Filter.serialize() | 266    * See Filter.serialize() | 
| 267    * @inheritdoc | 267    * @inheritdoc | 
| 268    */ | 268    */ | 
| 269   serialize(buffer) {} | 269   serialize(buffer) {} | 
| 270 }); | 270 }); | 
| 271 | 271 | 
| 272 /** | 272 /** | 
| 273  * Class for comments | 273  * Class for comments | 
| 274  * @param {string} text see Filter() | 274  * @param {string} text see {@link Filter Filter()} | 
| 275  * @constructor | 275  * @constructor | 
| 276  * @augments Filter | 276  * @augments Filter | 
| 277  */ | 277  */ | 
| 278 function CommentFilter(text) | 278 function CommentFilter(text) | 
| 279 { | 279 { | 
| 280   Filter.call(this, text); | 280   Filter.call(this, text); | 
| 281 } | 281 } | 
| 282 exports.CommentFilter = CommentFilter; | 282 exports.CommentFilter = CommentFilter; | 
| 283 | 283 | 
| 284 CommentFilter.prototype = extend(Filter, { | 284 CommentFilter.prototype = extend(Filter, { | 
| 285   type: "comment", | 285   type: "comment", | 
| 286 | 286 | 
| 287   /** | 287   /** | 
| 288    * See Filter.serialize() | 288    * See Filter.serialize() | 
| 289    * @inheritdoc | 289    * @inheritdoc | 
| 290    */ | 290    */ | 
| 291   serialize(buffer) {} | 291   serialize(buffer) {} | 
| 292 }); | 292 }); | 
| 293 | 293 | 
| 294 /** | 294 /** | 
| 295  * Abstract base class for filters that can get hits | 295  * Abstract base class for filters that can get hits | 
| 296  * @param {string} text | 296  * @param {string} text | 
| 297  *   see Filter() | 297  *   see {@link Filter Filter()} | 
| 298  * @param {string} [domains] | 298  * @param {string} [domains] | 
| 299  *   Domains that the filter is restricted to separated by domainSeparator | 299  *   Domains that the filter is restricted to separated by domainSeparator | 
| 300  *   e.g. "foo.com|bar.com|~baz.com" | 300  *   e.g. "foo.com|bar.com|~baz.com" | 
| 301  * @constructor | 301  * @constructor | 
| 302  * @augments Filter | 302  * @augments Filter | 
| 303  */ | 303  */ | 
| 304 function ActiveFilter(text, domains) | 304 function ActiveFilter(text, domains) | 
| 305 { | 305 { | 
| 306   Filter.call(this, text); | 306   Filter.call(this, text); | 
| 307 | 307 | 
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 552       if (this._hitCount) | 552       if (this._hitCount) | 
| 553         buffer.push("hitCount=" + this._hitCount); | 553         buffer.push("hitCount=" + this._hitCount); | 
| 554       if (this._lastHit) | 554       if (this._lastHit) | 
| 555         buffer.push("lastHit=" + this._lastHit); | 555         buffer.push("lastHit=" + this._lastHit); | 
| 556     } | 556     } | 
| 557   } | 557   } | 
| 558 }); | 558 }); | 
| 559 | 559 | 
| 560 /** | 560 /** | 
| 561  * Abstract base class for RegExp-based filters | 561  * Abstract base class for RegExp-based filters | 
| 562  * @param {string} text see Filter() | 562  * @param {string} text see {@link Filter Filter()} | 
| 563  * @param {string} regexpSource | 563  * @param {string} regexpSource | 
| 564  *   filter part that the regular expression should be build from | 564  *   filter part that the regular expression should be build from | 
| 565  * @param {number} [contentType] | 565  * @param {number} [contentType] | 
| 566  *   Content types the filter applies to, combination of values from | 566  *   Content types the filter applies to, combination of values from | 
| 567  *   RegExpFilter.typeMap | 567  *   RegExpFilter.typeMap | 
| 568  * @param {boolean} [matchCase] | 568  * @param {boolean} [matchCase] | 
| 569  *   Defines whether the filter should distinguish between lower and upper case | 569  *   Defines whether the filter should distinguish between lower and upper case | 
| 570  *   letters | 570  *   letters | 
| 571  * @param {string} [domains] | 571  * @param {string} [domains] | 
| 572  *   Domains that the filter is restricted to, e.g. "foo.com|bar.com|~baz.com" | 572  *   Domains that the filter is restricted to, e.g. "foo.com|bar.com|~baz.com" | 
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 857 // shouldn't be there by default | 857 // shouldn't be there by default | 
| 858 RegExpFilter.prototype.contentType &= ~(RegExpFilter.typeMap.CSP | | 858 RegExpFilter.prototype.contentType &= ~(RegExpFilter.typeMap.CSP | | 
| 859                                         RegExpFilter.typeMap.DOCUMENT | | 859                                         RegExpFilter.typeMap.DOCUMENT | | 
| 860                                         RegExpFilter.typeMap.ELEMHIDE | | 860                                         RegExpFilter.typeMap.ELEMHIDE | | 
| 861                                         RegExpFilter.typeMap.POPUP | | 861                                         RegExpFilter.typeMap.POPUP | | 
| 862                                         RegExpFilter.typeMap.GENERICHIDE | | 862                                         RegExpFilter.typeMap.GENERICHIDE | | 
| 863                                         RegExpFilter.typeMap.GENERICBLOCK); | 863                                         RegExpFilter.typeMap.GENERICBLOCK); | 
| 864 | 864 | 
| 865 /** | 865 /** | 
| 866  * Class for blocking filters | 866  * Class for blocking filters | 
| 867  * @param {string} text see Filter() | 867  * @param {string} text see {@link Filter Filter()} | 
| 868  * @param {string} regexpSource see RegExpFilter() | 868  * @param {string} regexpSource see {@link RegExpFilter RegExpFilter()} | 
| 869  * @param {number} [contentType] see RegExpFilter() | 869  * @param {number} [contentType] see {@link RegExpFilter RegExpFilter()} | 
| 870  * @param {boolean} [matchCase] see RegExpFilter() | 870  * @param {boolean} [matchCase] see {@link RegExpFilter RegExpFilter()} | 
| 871  * @param {string} [domains] see RegExpFilter() | 871  * @param {string} [domains] see {@link RegExpFilter RegExpFilter()} | 
| 872  * @param {boolean} [thirdParty] see RegExpFilter() | 872  * @param {boolean} [thirdParty] see {@link RegExpFilter RegExpFilter()} | 
| 873  * @param {string} [sitekeys] see RegExpFilter() | 873  * @param {string} [sitekeys] see {@link RegExpFilter RegExpFilter()} | 
| 874  * @param {boolean} [collapse] | 874  * @param {boolean} [collapse] | 
| 875  *   defines whether the filter should collapse blocked content, can be null | 875  *   defines whether the filter should collapse blocked content, can be null | 
| 876  * @param {string} [csp] | 876  * @param {string} [csp] | 
| 877  *   Content Security Policy to inject when the filter matches | 877  *   Content Security Policy to inject when the filter matches | 
| 878  * @param {?string} [rewrite] | 878  * @param {?string} [rewrite] | 
| 879  *   The (optional) rule specifying how to rewrite the URL. See | 879  *   The (optional) rule specifying how to rewrite the URL. See | 
| 880  *   BlockingFilter.prototype.rewrite. | 880  *   BlockingFilter.prototype.rewrite. | 
| 881  * @constructor | 881  * @constructor | 
| 882  * @augments RegExpFilter | 882  * @augments RegExpFilter | 
| 883  */ | 883  */ | 
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 937     catch (e) | 937     catch (e) | 
| 938     { | 938     { | 
| 939     } | 939     } | 
| 940 | 940 | 
| 941     return url; | 941     return url; | 
| 942   } | 942   } | 
| 943 }); | 943 }); | 
| 944 | 944 | 
| 945 /** | 945 /** | 
| 946  * Class for whitelist filters | 946  * Class for whitelist filters | 
| 947  * @param {string} text see Filter() | 947  * @param {string} text see {@link Filter Filter()} | 
| 948  * @param {string} regexpSource see RegExpFilter() | 948  * @param {string} regexpSource see {@link RegExpFilter RegExpFilter()} | 
| 949  * @param {number} [contentType] see RegExpFilter() | 949  * @param {number} [contentType] see {@link RegExpFilter RegExpFilter()} | 
| 950  * @param {boolean} [matchCase] see RegExpFilter() | 950  * @param {boolean} [matchCase] see {@link RegExpFilter RegExpFilter()} | 
| 951  * @param {string} [domains] see RegExpFilter() | 951  * @param {string} [domains] see {@link RegExpFilter RegExpFilter()} | 
| 952  * @param {boolean} [thirdParty] see RegExpFilter() | 952  * @param {boolean} [thirdParty] see {@link RegExpFilter RegExpFilter()} | 
| 953  * @param {string} [sitekeys] see RegExpFilter() | 953  * @param {string} [sitekeys] see {@link RegExpFilter RegExpFilter()} | 
| 954  * @constructor | 954  * @constructor | 
| 955  * @augments RegExpFilter | 955  * @augments RegExpFilter | 
| 956  */ | 956  */ | 
| 957 function WhitelistFilter(text, regexpSource, contentType, matchCase, domains, | 957 function WhitelistFilter(text, regexpSource, contentType, matchCase, domains, | 
| 958                          thirdParty, sitekeys) | 958                          thirdParty, sitekeys) | 
| 959 { | 959 { | 
| 960   RegExpFilter.call(this, text, regexpSource, contentType, matchCase, domains, | 960   RegExpFilter.call(this, text, regexpSource, contentType, matchCase, domains, | 
| 961                     thirdParty, sitekeys); | 961                     thirdParty, sitekeys); | 
| 962 } | 962 } | 
| 963 exports.WhitelistFilter = WhitelistFilter; | 963 exports.WhitelistFilter = WhitelistFilter; | 
| 964 | 964 | 
| 965 WhitelistFilter.prototype = extend(RegExpFilter, { | 965 WhitelistFilter.prototype = extend(RegExpFilter, { | 
| 966   type: "whitelist" | 966   type: "whitelist" | 
| 967 }); | 967 }); | 
| 968 | 968 | 
| 969 /** | 969 /** | 
| 970  * Base class for element hiding filters | 970  * Base class for element hiding filters | 
| 971  * @param {string} text see Filter() | 971  * @param {string} text see {@link Filter Filter()} | 
| 972  * @param {string} [domains] Host names or domains the filter should be | 972  * @param {string} [domains] Host names or domains the filter should be | 
| 973  *                           restricted to | 973  *                           restricted to | 
| 974  * @param {string} selector   CSS selector for the HTML elements that should be | 974  * @param {string} selector   CSS selector for the HTML elements that should be | 
| 975  *                            hidden | 975  *                            hidden | 
| 976  * @constructor | 976  * @constructor | 
| 977  * @augments ActiveFilter | 977  * @augments ActiveFilter | 
| 978  */ | 978  */ | 
| 979 function ElemHideBase(text, domains, selector) | 979 function ElemHideBase(text, domains, selector) | 
| 980 { | 980 { | 
| 981   ActiveFilter.call(this, text, domains || null); | 981   ActiveFilter.call(this, text, domains || null); | 
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1029       return new InvalidFilter(text, "filter_elemhideemulation_nodomain"); | 1029       return new InvalidFilter(text, "filter_elemhideemulation_nodomain"); | 
| 1030 | 1030 | 
| 1031     return new ElemHideEmulationFilter(text, domains, selector); | 1031     return new ElemHideEmulationFilter(text, domains, selector); | 
| 1032   } | 1032   } | 
| 1033 | 1033 | 
| 1034   return new ElemHideFilter(text, domains, selector); | 1034   return new ElemHideFilter(text, domains, selector); | 
| 1035 }; | 1035 }; | 
| 1036 | 1036 | 
| 1037 /** | 1037 /** | 
| 1038  * Class for element hiding filters | 1038  * Class for element hiding filters | 
| 1039  * @param {string} text see Filter() | 1039  * @param {string} text see {@link Filter Filter()} | 
| 1040  * @param {string} [domains]  see ElemHideBase() | 1040  * @param {string} [domains]  see {@link ElemHideBase ElemHideBase()} | 
| 1041  * @param {string} selector see ElemHideBase() | 1041  * @param {string} selector see {@link ElemHideBase ElemHideBase()} | 
| 1042  * @constructor | 1042  * @constructor | 
| 1043  * @augments ElemHideBase | 1043  * @augments ElemHideBase | 
| 1044  */ | 1044  */ | 
| 1045 function ElemHideFilter(text, domains, selector) | 1045 function ElemHideFilter(text, domains, selector) | 
| 1046 { | 1046 { | 
| 1047   ElemHideBase.call(this, text, domains, selector); | 1047   ElemHideBase.call(this, text, domains, selector); | 
| 1048 } | 1048 } | 
| 1049 exports.ElemHideFilter = ElemHideFilter; | 1049 exports.ElemHideFilter = ElemHideFilter; | 
| 1050 | 1050 | 
| 1051 ElemHideFilter.prototype = extend(ElemHideBase, { | 1051 ElemHideFilter.prototype = extend(ElemHideBase, { | 
| 1052   type: "elemhide" | 1052   type: "elemhide" | 
| 1053 }); | 1053 }); | 
| 1054 | 1054 | 
| 1055 /** | 1055 /** | 
| 1056  * Class for element hiding exceptions | 1056  * Class for element hiding exceptions | 
| 1057  * @param {string} text see Filter() | 1057  * @param {string} text see {@link Filter Filter()} | 
| 1058  * @param {string} [domains]  see ElemHideBase() | 1058  * @param {string} [domains]  see {@link ElemHideBase ElemHideBase()} | 
| 1059  * @param {string} selector see ElemHideBase() | 1059  * @param {string} selector see {@link ElemHideBase ElemHideBase()} | 
| 1060  * @constructor | 1060  * @constructor | 
| 1061  * @augments ElemHideBase | 1061  * @augments ElemHideBase | 
| 1062  */ | 1062  */ | 
| 1063 function ElemHideException(text, domains, selector) | 1063 function ElemHideException(text, domains, selector) | 
| 1064 { | 1064 { | 
| 1065   ElemHideBase.call(this, text, domains, selector); | 1065   ElemHideBase.call(this, text, domains, selector); | 
| 1066 } | 1066 } | 
| 1067 exports.ElemHideException = ElemHideException; | 1067 exports.ElemHideException = ElemHideException; | 
| 1068 | 1068 | 
| 1069 ElemHideException.prototype = extend(ElemHideBase, { | 1069 ElemHideException.prototype = extend(ElemHideBase, { | 
| 1070   type: "elemhideexception" | 1070   type: "elemhideexception" | 
| 1071 }); | 1071 }); | 
| 1072 | 1072 | 
| 1073 /** | 1073 /** | 
| 1074  * Class for element hiding emulation filters | 1074  * Class for element hiding emulation filters | 
| 1075  * @param {string} text           see Filter() | 1075  * @param {string} text           see {@link Filter Filter()} | 
| 1076  * @param {string} domains        see ElemHideBase() | 1076  * @param {string} domains        see {@link ElemHideBase ElemHideBase()} | 
| 1077  * @param {string} selector       see ElemHideBase() | 1077  * @param {string} selector       see {@link ElemHideBase ElemHideBase()} | 
| 1078  * @constructor | 1078  * @constructor | 
| 1079  * @augments ElemHideBase | 1079  * @augments ElemHideBase | 
| 1080  */ | 1080  */ | 
| 1081 function ElemHideEmulationFilter(text, domains, selector) | 1081 function ElemHideEmulationFilter(text, domains, selector) | 
| 1082 { | 1082 { | 
| 1083   ElemHideBase.call(this, text, domains, selector); | 1083   ElemHideBase.call(this, text, domains, selector); | 
| 1084 } | 1084 } | 
| 1085 exports.ElemHideEmulationFilter = ElemHideEmulationFilter; | 1085 exports.ElemHideEmulationFilter = ElemHideEmulationFilter; | 
| 1086 | 1086 | 
| 1087 ElemHideEmulationFilter.prototype = extend(ElemHideBase, { | 1087 ElemHideEmulationFilter.prototype = extend(ElemHideBase, { | 
| 1088   type: "elemhideemulation" | 1088   type: "elemhideemulation" | 
| 1089 }); | 1089 }); | 
| OLD | NEW | 
|---|