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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 * Retrieves an element hiding filter by the corresponding protocol key | 238 * Retrieves an element hiding filter by the corresponding protocol key |
239 * @param {number} key | 239 * @param {number} key |
240 * @return {Filter} | 240 * @return {Filter} |
241 */ | 241 */ |
242 getFilterByKey(key) | 242 getFilterByKey(key) |
243 { | 243 { |
244 return (key in filterByKey ? filterByKey[key] : null); | 244 return (key in filterByKey ? filterByKey[key] : null); |
245 }, | 245 }, |
246 | 246 |
247 /** | 247 /** |
248 * Returns a list of all selectors as a nested map. On first level, the keys | |
249 * are all values of `ElemHideBase.selectorDomain` (domains on which these | |
250 * selectors should apply, ignoring exceptions). The values are maps again, | |
251 * with the keys being selectors and values the corresponding filter keys. | |
252 * @returns {Map.<String,Map<String,String>>} | |
253 */ | |
254 getSelectors() | |
255 { | |
256 let domains = new Map(); | |
257 for (let key in filterByKey) | |
258 { | |
259 let filter = filterByKey[key]; | |
260 if (!filter.selector) | |
261 continue; | |
262 | |
263 let domain = filter.selectorDomain || ""; | |
264 | |
265 if (!domains.has(domain)) | |
266 domains.set(domain, new Map()); | |
267 domains.get(domain).set(filter.selector, key); | |
268 } | |
269 | |
270 return domains; | |
271 }, | |
272 | |
273 /** | |
274 * Returns a list of selectors that apply on each website unconditionally. | 248 * Returns a list of selectors that apply on each website unconditionally. |
275 * @returns {string[]} | 249 * @returns {string[]} |
276 */ | 250 */ |
277 getUnconditionalSelectors() | 251 getUnconditionalSelectors() |
278 { | 252 { |
279 if (!unconditionalSelectors) | 253 if (!unconditionalSelectors) |
280 unconditionalSelectors = [...filterKeyBySelector.keys()]; | 254 unconditionalSelectors = [...filterKeyBySelector.keys()]; |
281 return unconditionalSelectors.slice(); | 255 return unconditionalSelectors.slice(); |
282 }, | 256 }, |
283 | 257 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 if (currentDomain == "") | 317 if (currentDomain == "") |
344 break; | 318 break; |
345 | 319 |
346 let nextDot = currentDomain.indexOf("."); | 320 let nextDot = currentDomain.indexOf("."); |
347 currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1); | 321 currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1); |
348 } | 322 } |
349 | 323 |
350 return selectors; | 324 return selectors; |
351 } | 325 } |
352 }; | 326 }; |
OLD | NEW |