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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 parser(null); | 436 parser(null); |
437 return this.saveToDisk(); | 437 return this.saveToDisk(); |
438 }); | 438 }); |
439 }, | 439 }, |
440 | 440 |
441 /** | 441 /** |
442 * Generator serializing filter data and yielding it line by line. | 442 * Generator serializing filter data and yielding it line by line. |
443 */ | 443 */ |
444 *exportData() | 444 *exportData() |
445 { | 445 { |
446 // Do not persist external subscriptions | |
447 let subscriptions = []; | |
448 for (let subscription of this.subscriptions()) | |
449 { | |
450 if (!(subscription instanceof ExternalSubscription) && | |
451 !(subscription instanceof SpecialSubscription && | |
452 subscription.filters.length == 0)) | |
453 { | |
454 subscriptions.push(subscription); | |
455 } | |
456 } | |
457 | |
458 yield "# Adblock Plus preferences"; | 446 yield "# Adblock Plus preferences"; |
459 yield "version=" + formatVersion; | 447 yield "version=" + formatVersion; |
460 | 448 |
461 let saved = new Set(); | 449 let saved = new Set(); |
462 let buf = []; | 450 let buf = []; |
463 | 451 |
464 // Save subscriptions | 452 // Save subscriptions |
465 for (let subscription of subscriptions) | 453 for (let subscription of this.subscriptions()) |
466 { | 454 { |
| 455 // Do not persist external subscriptions, special subscriptions |
| 456 // and subscriptions with no filters. |
| 457 if (subscription instanceof ExternalSubscription || |
| 458 subscription instanceof SpecialSubscription && |
| 459 subscription.filters.length == 0) |
| 460 { |
| 461 continue; |
| 462 } |
| 463 |
467 yield ""; | 464 yield ""; |
| 465 subscription.serialize(buf); |
468 | 466 |
469 subscription.serialize(buf); | |
470 if (subscription.filters.length) | 467 if (subscription.filters.length) |
471 { | 468 { |
472 buf.push("", "[Subscription filters]"); | 469 buf.push("", "[Subscription filters]"); |
473 subscription.serializeFilters(buf); | 470 subscription.serializeFilters(buf); |
474 } | 471 } |
| 472 |
475 for (let line of buf) | 473 for (let line of buf) |
476 yield line; | 474 yield line; |
477 buf.splice(0); | 475 buf.splice(0); |
478 } | |
479 | 476 |
480 // Save filter data | 477 // Save filter data |
481 for (let subscription of subscriptions) | |
482 { | |
483 for (let filter of subscription.filters) | 478 for (let filter of subscription.filters) |
484 { | 479 { |
485 if (!saved.has(filter.text)) | 480 if (!saved.has(filter.text)) |
486 { | 481 { |
487 filter.serialize(buf); | 482 filter.serialize(buf); |
488 saved.add(filter.text); | 483 saved.add(filter.text); |
489 for (let line of buf) | 484 for (let line of buf) |
490 yield line; | 485 yield line; |
491 buf.splice(0); | 486 buf.splice(0); |
492 } | 487 } |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 * @param {Subscription} subscription filter subscription to be removed | 649 * @param {Subscription} subscription filter subscription to be removed |
655 */ | 650 */ |
656 function removeSubscriptionFilters(subscription) | 651 function removeSubscriptionFilters(subscription) |
657 { | 652 { |
658 if (!FilterStorage.knownSubscriptions.has(subscription.url)) | 653 if (!FilterStorage.knownSubscriptions.has(subscription.url)) |
659 return; | 654 return; |
660 | 655 |
661 for (let filter of subscription.filters) | 656 for (let filter of subscription.filters) |
662 filter.removeSubscription(subscription); | 657 filter.removeSubscription(subscription); |
663 } | 658 } |
OLD | NEW |