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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 else | 141 else |
142 filter = RegExpFilter.fromText(text); | 142 filter = RegExpFilter.fromText(text); |
143 | 143 |
144 Filter.knownFilters.set(filter.text, filter); | 144 Filter.knownFilters.set(filter.text, filter); |
145 return filter; | 145 return filter; |
146 }; | 146 }; |
147 | 147 |
148 /** | 148 /** |
149 * Deserializes a filter | 149 * Deserializes a filter |
150 * | 150 * |
151 * @param {Object} obj map of serialized properties and their values | 151 * @param {Map.<string,string>} map map of serialized properties and their |
| 152 * values |
152 * @return {Filter} filter or null if the filter couldn't be created | 153 * @return {Filter} filter or null if the filter couldn't be created |
153 */ | 154 */ |
154 Filter.fromObject = function(obj) | 155 Filter.fromMap = function(map) |
155 { | 156 { |
156 let filter = Filter.fromText(obj.text); | 157 let filter = Filter.fromText(map.get("text")); |
157 if (filter instanceof ActiveFilter) | 158 if (filter instanceof ActiveFilter) |
158 { | 159 { |
159 if ("disabled" in obj) | 160 let disabled = map.get("disabled"); |
160 filter._disabled = (obj.disabled == "true"); | 161 let hitCount = map.get("hitCount"); |
161 if ("hitCount" in obj) | 162 let lastHit = map.get("lastHit"); |
162 filter._hitCount = parseInt(obj.hitCount, 10) || 0; | 163 if (typeof disabled != "undefined") |
163 if ("lastHit" in obj) | 164 filter._disabled = (disabled == "true"); |
164 filter._lastHit = parseInt(obj.lastHit, 10) || 0; | 165 if (typeof hitCount != "undefined") |
| 166 filter._hitCount = parseInt(hitCount, 10) || 0; |
| 167 if (typeof lastHit != "undefined") |
| 168 filter._lastHit = parseInt(lastHit, 10) || 0; |
165 } | 169 } |
166 return filter; | 170 return filter; |
167 }; | 171 }; |
168 | 172 |
169 /** | 173 /** |
170 * Removes unnecessary whitespaces from filter text, will only return null if | 174 * Removes unnecessary whitespaces from filter text, will only return null if |
171 * the input parameter is null. | 175 * the input parameter is null. |
172 * @param {string} text | 176 * @param {string} text |
173 * @return {string} | 177 * @return {string} |
174 */ | 178 */ |
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1080 */ | 1084 */ |
1081 function ElemHideEmulationFilter(text, domains, selector) | 1085 function ElemHideEmulationFilter(text, domains, selector) |
1082 { | 1086 { |
1083 ElemHideBase.call(this, text, domains, selector); | 1087 ElemHideBase.call(this, text, domains, selector); |
1084 } | 1088 } |
1085 exports.ElemHideEmulationFilter = ElemHideEmulationFilter; | 1089 exports.ElemHideEmulationFilter = ElemHideEmulationFilter; |
1086 | 1090 |
1087 ElemHideEmulationFilter.prototype = extend(ElemHideBase, { | 1091 ElemHideEmulationFilter.prototype = extend(ElemHideBase, { |
1088 type: "elemhideemulation" | 1092 type: "elemhideemulation" |
1089 }); | 1093 }); |
OLD | NEW |