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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 "use strict"; | 18 "use strict"; |
19 | 19 |
20 /** | 20 /** |
21 * @fileOverview Element hiding implementation. | 21 * @fileOverview Element hiding implementation. |
22 */ | 22 */ |
23 | 23 |
24 const {ElemHideExceptions} = require("./elemHideExceptions"); | 24 const {ElemHideExceptions} = require("./elemHideExceptions"); |
25 const {filterNotifier} = require("./filterNotifier"); | 25 const {filterNotifier} = require("./filterNotifier"); |
26 const {normalizeHostname, suffixes} = require("./domain"); | 26 const {normalizeHostname, domainSuffixes} = require("./url"); |
27 | 27 |
28 /** | 28 /** |
29 * The maximum number of selectors in a CSS rule. This is used by | 29 * The maximum number of selectors in a CSS rule. This is used by |
30 * <code>{@link createStyleSheet}</code> to split up a long list of selectors | 30 * <code>{@link createStyleSheet}</code> to split up a long list of selectors |
31 * into multiple rules. | 31 * into multiple rules. |
32 * @const {number} | 32 * @const {number} |
33 * @default | 33 * @default |
34 */ | 34 */ |
35 const selectorGroupSize = 1024; | 35 const selectorGroupSize = 1024; |
36 | 36 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 * be included. | 164 * be included. |
165 * | 165 * |
166 * @returns {Array.<string>} The list of selectors. | 166 * @returns {Array.<string>} The list of selectors. |
167 */ | 167 */ |
168 function getConditionalSelectors(domain, specificOnly) | 168 function getConditionalSelectors(domain, specificOnly) |
169 { | 169 { |
170 let selectors = []; | 170 let selectors = []; |
171 | 171 |
172 let excluded = new Set(); | 172 let excluded = new Set(); |
173 | 173 |
174 for (let currentDomain of suffixes(domain, !specificOnly)) | 174 for (let currentDomain of domainSuffixes(domain, !specificOnly)) |
175 { | 175 { |
176 let filters = filtersByDomain.get(currentDomain); | 176 let filters = filtersByDomain.get(currentDomain); |
177 if (filters) | 177 if (filters) |
178 { | 178 { |
179 for (let [filter, isIncluded] of filters) | 179 for (let [filter, isIncluded] of filters) |
180 { | 180 { |
181 if (!isIncluded) | 181 if (!isIncluded) |
182 { | 182 { |
183 excluded.add(filter); | 183 excluded.add(filter); |
184 } | 184 } |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 { | 503 { |
504 let styleSheet = ""; | 504 let styleSheet = ""; |
505 | 505 |
506 for (let selectorGroup of splitSelectors(selectors)) | 506 for (let selectorGroup of splitSelectors(selectors)) |
507 styleSheet += createRule(selectorGroup); | 507 styleSheet += createRule(selectorGroup); |
508 | 508 |
509 return styleSheet; | 509 return styleSheet; |
510 } | 510 } |
511 | 511 |
512 exports.createStyleSheet = createStyleSheet; | 512 exports.createStyleSheet = createStyleSheet; |
OLD | NEW |