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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 * @return {Filter} | 101 * @return {Filter} |
102 */ | 102 */ |
103 Filter.fromText = function(text) | 103 Filter.fromText = function(text) |
104 { | 104 { |
105 if (text in Filter.knownFilters) | 105 if (text in Filter.knownFilters) |
106 return Filter.knownFilters[text]; | 106 return Filter.knownFilters[text]; |
107 | 107 |
108 let ret; | 108 let ret; |
109 let match = (text.indexOf("#") >= 0 ? Filter.elemhideRegExp.exec(text) : null)
; | 109 let match = (text.indexOf("#") >= 0 ? Filter.elemhideRegExp.exec(text) : null)
; |
110 if (match) | 110 if (match) |
111 ret = ElemHideBase.fromText(text, match[1], match[2], match[3], match[4], ma
tch[5]); | 111 ret = ElemHideBase.fromText(text, match[1], !!match[2], match[3], match[4],
match[5]); |
112 else if (text[0] == "!") | 112 else if (text[0] == "!") |
113 ret = new CommentFilter(text); | 113 ret = new CommentFilter(text); |
114 else | 114 else |
115 ret = RegExpFilter.fromText(text); | 115 ret = RegExpFilter.fromText(text); |
116 | 116 |
117 Filter.knownFilters[ret.text] = ret; | 117 Filter.knownFilters[ret.text] = ret; |
118 return ret; | 118 return ret; |
119 }; | 119 }; |
120 | 120 |
121 /** | 121 /** |
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 /** | 855 /** |
856 * CSS selector for the HTML elements that should be hidden | 856 * CSS selector for the HTML elements that should be hidden |
857 * @type String | 857 * @type String |
858 */ | 858 */ |
859 selector: null | 859 selector: null |
860 }; | 860 }; |
861 | 861 |
862 /** | 862 /** |
863 * Creates an element hiding filter from a pre-parsed text representation | 863 * Creates an element hiding filter from a pre-parsed text representation |
864 * | 864 * |
865 * @param {String} text same as in Filter() | 865 * @param {String} text same as in Filter() |
866 * @param {String} domain domain part of the text representation (can be emp
ty) | 866 * @param {String} domain domain part of the text representation (can be e
mpty) |
867 * @param {String} tagName tag name part (can be empty) | 867 * @param {Boolean} isException exception rule indicator |
868 * @param {String} attrRules attribute matching rules (can be empty) | 868 * @param {String} tagName tag name part (can be empty) |
869 * @param {String} selector raw CSS selector (can be empty) | 869 * @param {String} attrRules attribute matching rules (can be empty) |
| 870 * @param {String} selector raw CSS selector (can be empty) |
870 * @return {ElemHideFilter|ElemHideException|CSSPropertyFilter|InvalidFilter} | 871 * @return {ElemHideFilter|ElemHideException|CSSPropertyFilter|InvalidFilter} |
871 */ | 872 */ |
872 ElemHideBase.fromText = function(text, domain, isException, tagName, attrRules,
selector) | 873 ElemHideBase.fromText = function(text, domain, isException, tagName, attrRules,
selector) |
873 { | 874 { |
874 if (!selector) | 875 if (!selector) |
875 { | 876 { |
876 if (tagName == "*") | 877 if (tagName == "*") |
877 tagName = ""; | 878 tagName = ""; |
878 | 879 |
879 let id = null; | 880 let id = null; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 // several times on Safari, due to WebKit bug 132872 | 1022 // several times on Safari, due to WebKit bug 132872 |
1022 let prop = Object.getOwnPropertyDescriptor(this, "regexpString"); | 1023 let prop = Object.getOwnPropertyDescriptor(this, "regexpString"); |
1023 if (prop) | 1024 if (prop) |
1024 return prop.value; | 1025 return prop.value; |
1025 | 1026 |
1026 let regexp = Filter.toRegExp(this.regexpSource); | 1027 let regexp = Filter.toRegExp(this.regexpSource); |
1027 Object.defineProperty(this, "regexpString", {value: regexp}); | 1028 Object.defineProperty(this, "regexpString", {value: regexp}); |
1028 return regexp; | 1029 return regexp; |
1029 } | 1030 } |
1030 }; | 1031 }; |
OLD | NEW |