| 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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 * @property {Array.<string>} selectors List of selectors. | 352 * @property {Array.<string>} selectors List of selectors. |
| 353 */ | 353 */ |
| 354 | 354 |
| 355 /** | 355 /** |
| 356 * Generates a style sheet for a given domain based on the current set of | 356 * Generates a style sheet for a given domain based on the current set of |
| 357 * filters. | 357 * filters. |
| 358 * | 358 * |
| 359 * @param {string} domain The domain. | 359 * @param {string} domain The domain. |
| 360 * @param {boolean} [specificOnly=false] Whether selectors from generic | 360 * @param {boolean} [specificOnly=false] Whether selectors from generic |
| 361 * filters should be included. | 361 * filters should be included. |
| 362 * @param {boolean} [includeSelectors=true] Whether the return value should |
| 363 * include a separate list of selectors. |
| 362 * | 364 * |
| 363 * @returns {ElemHideStyleSheet} An object containing the CSS code and the | 365 * @returns {ElemHideStyleSheet} An object containing the CSS code and the |
| 364 * list of selectors. | 366 * list of selectors. |
| 365 */ | 367 */ |
| 366 generateStyleSheetForDomain(domain, specificOnly = false) | 368 generateStyleSheetForDomain(domain, specificOnly = false, |
| 369 includeSelectors = true) |
| 367 { | 370 { |
| 368 let knownSuffix = domain ? getKnownSuffix(domain) : ""; | 371 let knownSuffix = domain ? getKnownSuffix(domain) : ""; |
| 369 | 372 |
| 370 let selectors = getConditionalSelectorsForDomain(knownSuffix, specificOnly); | 373 let selectors = []; |
| 374 if (includeSelectors || knownSuffix != "") |
| 375 selectors = getConditionalSelectorsForDomain(knownSuffix, specificOnly); |
| 376 |
| 371 let code = specificOnly ? createStyleSheet(selectors) : | 377 let code = specificOnly ? createStyleSheet(selectors) : |
| 372 knownSuffix == "" ? getCommonStyleSheet() : | 378 knownSuffix == "" ? getCommonStyleSheet() : |
| 373 (getDefaultStyleSheet() + createStyleSheet(selectors)); | 379 (getDefaultStyleSheet() + createStyleSheet(selectors)); |
| 374 | 380 |
| 375 if (!specificOnly) | 381 if (includeSelectors && !specificOnly) |
| 376 selectors = getUnconditionalSelectors().concat(selectors); | 382 selectors = getUnconditionalSelectors().concat(selectors); |
| 377 | 383 |
| 378 return {code, selectors}; | 384 return {code, selectors: includeSelectors ? selectors : null}; |
| 379 } | 385 } |
| 380 }; | 386 }; |
| 381 | 387 |
| 382 /** | 388 /** |
| 383 * Splits a list of selectors into groups determined by the value of | 389 * Splits a list of selectors into groups determined by the value of |
| 384 * <code>{@link selectorGroupSize}</code>. | 390 * <code>{@link selectorGroupSize}</code>. |
| 385 * | 391 * |
| 386 * @param {Array.<string>} selectors | 392 * @param {Array.<string>} selectors |
| 387 * @yields {Array.<string>} | 393 * @yields {Array.<string>} |
| 388 */ | 394 */ |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 { | 436 { |
| 431 let styleSheet = ""; | 437 let styleSheet = ""; |
| 432 | 438 |
| 433 for (let selectorGroup of splitSelectors(selectors)) | 439 for (let selectorGroup of splitSelectors(selectors)) |
| 434 styleSheet += createRule(selectorGroup); | 440 styleSheet += createRule(selectorGroup); |
| 435 | 441 |
| 436 return styleSheet; | 442 return styleSheet; |
| 437 } | 443 } |
| 438 | 444 |
| 439 exports.createStyleSheet = createStyleSheet; | 445 exports.createStyleSheet = createStyleSheet; |
| OLD | NEW |