Left: | ||
Right: |
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 */ | 65 */ |
66 let exceptions = new Map(); | 66 let exceptions = new Map(); |
67 | 67 |
68 /** | 68 /** |
69 * Adds a filter to the lookup table of filters by domain. | 69 * Adds a filter to the lookup table of filters by domain. |
70 * @param {Filter} filter | 70 * @param {Filter} filter |
71 */ | 71 */ |
72 function addToFiltersByDomain(filter) | 72 function addToFiltersByDomain(filter) |
73 { | 73 { |
74 let domains = filter.domains || defaultDomains; | 74 let domains = filter.domains || defaultDomains; |
75 | |
76 if (typeof domains == "string") | |
sergei
2018/05/28 09:22:07
Will the refactoring of that `typeof DOMAINS == "s
kzar
2018/06/05 16:51:30
Agreed, if possible (without messing up performanc
| |
77 domains = [[domains, true]]; | |
78 | |
75 for (let [domain, isIncluded] of domains) | 79 for (let [domain, isIncluded] of domains) |
76 { | 80 { |
77 // There's no need to note that a filter is generically disabled. | 81 // There's no need to note that a filter is generically disabled. |
78 if (!isIncluded && domain == "") | 82 if (!isIncluded && domain == "") |
79 continue; | 83 continue; |
80 | 84 |
81 let filters = filtersByDomain.get(domain); | 85 let filters = filtersByDomain.get(domain); |
82 if (!filters) | 86 if (!filters) |
83 filtersByDomain.set(domain, filters = new Map()); | 87 filtersByDomain.set(domain, filters = new Map()); |
84 filters.set(filter, isIncluded); | 88 filters.set(filter, isIncluded); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
181 // Unconditially applied element hiding filters | 185 // Unconditially applied element hiding filters |
182 else if (filterBySelector.get(filter.selector) == filter) | 186 else if (filterBySelector.get(filter.selector) == filter) |
183 { | 187 { |
184 filterBySelector.delete(filter.selector); | 188 filterBySelector.delete(filter.selector); |
185 unconditionalSelectors = null; | 189 unconditionalSelectors = null; |
186 } | 190 } |
187 // Conditionally applied element hiding filters | 191 // Conditionally applied element hiding filters |
188 else | 192 else |
189 { | 193 { |
190 let domains = filter.domains || defaultDomains; | 194 let domains = filter.domains || defaultDomains; |
191 for (let domain of domains.keys()) | 195 |
196 if (typeof domains == "string") | |
197 domains = [[domains]]; | |
198 | |
199 for (let [domain] of domains) | |
192 { | 200 { |
193 let filters = filtersByDomain.get(domain); | 201 let filters = filtersByDomain.get(domain); |
194 if (filters) | 202 if (filters) |
195 filters.delete(filter); | 203 filters.delete(filter); |
196 } | 204 } |
197 } | 205 } |
198 | 206 |
199 knownFilters.delete(filter); | 207 knownFilters.delete(filter); |
200 FilterNotifier.emit("elemhideupdate"); | 208 FilterNotifier.emit("elemhideupdate"); |
201 }, | 209 }, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 let nextDot = currentDomain.indexOf("."); | 274 let nextDot = currentDomain.indexOf("."); |
267 currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1); | 275 currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1); |
268 } | 276 } |
269 | 277 |
270 if (!specificOnly) | 278 if (!specificOnly) |
271 selectors = getUnconditionalSelectors().concat(selectors); | 279 selectors = getUnconditionalSelectors().concat(selectors); |
272 | 280 |
273 return selectors; | 281 return selectors; |
274 } | 282 } |
275 }; | 283 }; |
OLD | NEW |