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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 /** | 235 /** |
236 * Determines from the current filter list which selectors should be applied | 236 * Determines from the current filter list which selectors should be applied |
237 * on a particular host name. | 237 * on a particular host name. |
238 * @param {string} domain | 238 * @param {string} domain |
239 * @param {number} [criteria] | 239 * @param {number} [criteria] |
240 * One of the following: ElemHide.ALL_MATCHING, ElemHide.NO_UNCONDITIONAL or | 240 * One of the following: ElemHide.ALL_MATCHING, ElemHide.NO_UNCONDITIONAL or |
241 * ElemHide.SPECIFIC_ONLY. | 241 * ElemHide.SPECIFIC_ONLY. |
242 * @returns {string[]} | 242 * @returns {string[]} |
243 * List of selectors. | 243 * List of selectors. |
244 */ | 244 */ |
245 getSelectorsForDomain(domain, criteria) | 245 getSelectorsForDomain(domain, criteria = ElemHide.ALL_MATCHING) |
246 { | 246 { |
247 let selectors = []; | 247 let selectors = []; |
248 | 248 |
249 if (typeof criteria == "undefined") | |
250 criteria = ElemHide.ALL_MATCHING; | |
251 if (criteria < ElemHide.NO_UNCONDITIONAL) | 249 if (criteria < ElemHide.NO_UNCONDITIONAL) |
252 selectors = this.getUnconditionalSelectors(); | 250 selectors = this.getUnconditionalSelectors(); |
253 | 251 |
254 let specificOnly = (criteria >= ElemHide.SPECIFIC_ONLY); | 252 let specificOnly = (criteria >= ElemHide.SPECIFIC_ONLY); |
255 let excluded = new Set(); | 253 let excluded = new Set(); |
256 let currentDomain = domain ? domain.toUpperCase() : ""; | 254 let currentDomain = domain ? domain.toUpperCase() : ""; |
257 | 255 |
258 // This code is a performance hot-spot, which is why we've made certain | 256 // This code is a performance hot-spot, which is why we've made certain |
259 // micro-optimisations. Please be careful before making changes. | 257 // micro-optimisations. Please be careful before making changes. |
260 while (true) | 258 while (true) |
(...skipping 21 matching lines...) Expand all Loading... |
282 if (currentDomain == "") | 280 if (currentDomain == "") |
283 break; | 281 break; |
284 | 282 |
285 let nextDot = currentDomain.indexOf("."); | 283 let nextDot = currentDomain.indexOf("."); |
286 currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1); | 284 currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1); |
287 } | 285 } |
288 | 286 |
289 return selectors; | 287 return selectors; |
290 } | 288 } |
291 }; | 289 }; |
OLD | NEW |