| 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 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 else | 442 else |
| 443 { | 443 { |
| 444 customFilters.push(filter.text); | 444 customFilters.push(filter.text); |
| 445 if (isCustomFiltersLoaded) | 445 if (isCustomFiltersLoaded) |
| 446 updateCustomFiltersUi(); | 446 updateCustomFiltersUi(); |
| 447 } | 447 } |
| 448 | 448 |
| 449 filtersMap[filter.text] = filter; | 449 filtersMap[filter.text] = filter; |
| 450 } | 450 } |
| 451 | 451 |
| 452 function loadCustomFilters(filters) |
| 453 { |
| 454 for (let filter of filters) |
| 455 updateFilter(filter); |
| 456 |
| 457 setCustomFiltersView("read"); |
| 458 isCustomFiltersLoaded = true; |
| 459 } |
| 460 |
| 452 function removeCustomFilter(text) | 461 function removeCustomFilter(text) |
| 453 { | 462 { |
| 454 let index = customFilters.indexOf(text); | 463 let index = customFilters.indexOf(text); |
| 455 if (index >= 0) | 464 if (index >= 0) |
| 456 customFilters.splice(index, 1); | 465 customFilters.splice(index, 1); |
| 457 | 466 |
| 458 updateCustomFiltersUi(); | 467 updateCustomFiltersUi(); |
| 459 } | 468 } |
| 460 | 469 |
| 461 function updateCustomFiltersUi() | 470 function updateCustomFiltersUi() |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 | 1057 |
| 1049 function populateLists() | 1058 function populateLists() |
| 1050 { | 1059 { |
| 1051 subscriptionsMap = Object.create(null); | 1060 subscriptionsMap = Object.create(null); |
| 1052 filtersMap = Object.create(null); | 1061 filtersMap = Object.create(null); |
| 1053 | 1062 |
| 1054 // Empty collections and lists | 1063 // Empty collections and lists |
| 1055 for (let property in collections) | 1064 for (let property in collections) |
| 1056 collections[property].clearAll(); | 1065 collections[property].clearAll(); |
| 1057 | 1066 |
| 1067 setCustomFiltersView("empty"); |
| 1058 ext.backgroundPage.sendMessage({ | 1068 ext.backgroundPage.sendMessage({ |
| 1059 type: "subscriptions.get", | 1069 type: "subscriptions.get", |
| 1060 special: true | 1070 special: true |
| 1061 }, | 1071 }, |
| 1062 (subscriptions) => | 1072 (subscriptions) => |
| 1063 { | 1073 { |
| 1064 // Load filters | 1074 // Load filters |
| 1065 for (let subscription of subscriptions) | 1075 for (let subscription of subscriptions) |
| 1066 { | 1076 { |
| 1067 ext.backgroundPage.sendMessage({ | 1077 ext.backgroundPage.sendMessage({ |
| 1068 type: "filters.get", | 1078 type: "filters.get", |
| 1069 subscriptionUrl: subscription.url | 1079 subscriptionUrl: subscription.url |
| 1070 }, | 1080 }, |
| 1071 (filters) => | 1081 (filters) => |
| 1072 { | 1082 { |
| 1073 for (let filter of filters) | 1083 loadCustomFilters(filters); |
| 1074 updateFilter(filter); | |
| 1075 | |
| 1076 isCustomFiltersLoaded = true; | |
| 1077 setCustomFiltersView("read"); | |
| 1078 }); | 1084 }); |
| 1079 } | 1085 } |
| 1080 }); | 1086 }); |
| 1081 loadRecommendations(); | 1087 loadRecommendations(); |
| 1082 ext.backgroundPage.sendMessage({ | 1088 ext.backgroundPage.sendMessage({ |
| 1083 type: "prefs.get", | 1089 type: "prefs.get", |
| 1084 key: "subscriptions_exceptionsurl" | 1090 key: "subscriptions_exceptionsurl" |
| 1085 }, | 1091 }, |
| 1086 (url) => | 1092 (url) => |
| 1087 { | 1093 { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1203 break; | 1209 break; |
| 1204 case "downloading": | 1210 case "downloading": |
| 1205 case "downloadStatus": | 1211 case "downloadStatus": |
| 1206 case "homepage": | 1212 case "homepage": |
| 1207 case "lastDownload": | 1213 case "lastDownload": |
| 1208 case "title": | 1214 case "title": |
| 1209 updateSubscription(subscription); | 1215 updateSubscription(subscription); |
| 1210 break; | 1216 break; |
| 1211 case "added": | 1217 case "added": |
| 1212 let {url, recommended} = subscription; | 1218 let {url, recommended} = subscription; |
| 1213 if (url in subscriptionsMap) | 1219 // Handle custom subscription |
| 1220 if (/^~user/.test(url)) |
| 1221 { |
| 1222 loadCustomFilters(subscription.filters); |
| 1223 return; |
| 1224 } |
| 1225 else if (url in subscriptionsMap) |
| 1214 updateSubscription(subscription); | 1226 updateSubscription(subscription); |
| 1215 else | 1227 else |
| 1216 addSubscription(subscription); | 1228 addSubscription(subscription); |
| 1217 | 1229 |
| 1218 if (isAcceptableAds(url)) | 1230 if (isAcceptableAds(url)) |
| 1219 setAcceptableAds(); | 1231 setAcceptableAds(); |
| 1220 | 1232 |
| 1221 if ((url == acceptableAdsUrl || recommended == "privacy") && | 1233 if ((url == acceptableAdsUrl || recommended == "privacy") && |
| 1222 hasPrivacyConflict()) | 1234 hasPrivacyConflict()) |
| 1223 { | 1235 { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1381 }); | 1393 }); |
| 1382 ext.backgroundPage.sendMessage({ | 1394 ext.backgroundPage.sendMessage({ |
| 1383 type: "subscriptions.listen", | 1395 type: "subscriptions.listen", |
| 1384 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1396 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
| 1385 "title", "downloadStatus", "downloading"] | 1397 "title", "downloadStatus", "downloading"] |
| 1386 }); | 1398 }); |
| 1387 | 1399 |
| 1388 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1400 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
| 1389 window.addEventListener("hashchange", onHashChange, false); | 1401 window.addEventListener("hashchange", onHashChange, false); |
| 1390 } | 1402 } |
| OLD | NEW |