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 /* globals checkShareResource, getDocLink, i18nFormatDateTime, openSharePopup, | 18 /* globals checkShareResource, getDocLink, i18nFormatDateTime, openSharePopup, |
19 setLinks, E */ | 19 setLinks, E */ |
20 | 20 |
21 "use strict"; | 21 "use strict"; |
22 | 22 |
23 { | 23 { |
24 let subscriptionsMap = Object.create(null); | 24 let subscriptionsMap = Object.create(null); |
25 let filtersMap = Object.create(null); | 25 let filtersMap = Object.create(null); |
26 let collections = Object.create(null); | 26 let collections = Object.create(null); |
27 let acceptableAdsUrl = null; | 27 let acceptableAdsUrl = null; |
28 let acceptableAdsPrivacyUrl = null; | 28 let acceptableAdsPrivacyUrl = null; |
29 let isCustomFiltersLoaded = false; | 29 let isCustomFiltersLoaded = false; |
| 30 let isSubscriptionsLoaded = false; |
30 let {getMessage} = ext.i18n; | 31 let {getMessage} = ext.i18n; |
31 let customFilters = []; | 32 let customFilters = []; |
32 let filterErrors = new Map([ | 33 let filterErrors = new Map([ |
33 ["synchronize_invalid_url", | 34 ["synchronize_invalid_url", |
34 "options_filterList_lastDownload_invalidURL"], | 35 "options_filterList_lastDownload_invalidURL"], |
35 ["synchronize_connection_error", | 36 ["synchronize_connection_error", |
36 "options_filterList_lastDownload_connectionError"], | 37 "options_filterList_lastDownload_connectionError"], |
37 ["synchronize_invalid_data", | 38 ["synchronize_invalid_data", |
38 "options_filterList_lastDownload_invalidData"], | 39 "options_filterList_lastDownload_invalidData"], |
39 ["synchronize_checksum_mismatch", | 40 ["synchronize_checksum_mismatch", |
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1001 document.forms["acceptable-ads"].classList.add("show-dnt-notification"); | 1002 document.forms["acceptable-ads"].classList.add("show-dnt-notification"); |
1002 } | 1003 } |
1003 document.forms["acceptable-ads"]["acceptable-ads"].value = option; | 1004 document.forms["acceptable-ads"]["acceptable-ads"].value = option; |
1004 } | 1005 } |
1005 | 1006 |
1006 function isAcceptableAds(url) | 1007 function isAcceptableAds(url) |
1007 { | 1008 { |
1008 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; | 1009 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; |
1009 } | 1010 } |
1010 | 1011 |
| 1012 function isPrivacyAndAdsEnabled() |
| 1013 { |
| 1014 let isAcceptableAds = subscriptionsMap[acceptableAdsUrl]; |
| 1015 isAcceptableAds = isAcceptableAds && isAcceptableAds.disabled == false; |
| 1016 for (let url in subscriptionsMap) |
| 1017 { |
| 1018 let subscription = subscriptionsMap[url]; |
| 1019 if (subscription.recommended == "privacy") |
| 1020 return subscription.disabled == false && isAcceptableAds; |
| 1021 } |
| 1022 } |
| 1023 |
1011 function populateLists() | 1024 function populateLists() |
1012 { | 1025 { |
1013 subscriptionsMap = Object.create(null); | 1026 subscriptionsMap = Object.create(null); |
1014 filtersMap = Object.create(null); | 1027 filtersMap = Object.create(null); |
1015 | 1028 |
1016 // Empty collections and lists | 1029 // Empty collections and lists |
1017 for (let property in collections) | 1030 for (let property in collections) |
1018 collections[property].clearAll(); | 1031 collections[property].clearAll(); |
1019 | 1032 |
1020 ext.backgroundPage.sendMessage({ | 1033 ext.backgroundPage.sendMessage({ |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 | 1076 |
1064 // Load user subscriptions | 1077 // Load user subscriptions |
1065 ext.backgroundPage.sendMessage({ | 1078 ext.backgroundPage.sendMessage({ |
1066 type: "subscriptions.get", | 1079 type: "subscriptions.get", |
1067 downloadable: true | 1080 downloadable: true |
1068 }, | 1081 }, |
1069 (subscriptions) => | 1082 (subscriptions) => |
1070 { | 1083 { |
1071 for (let subscription of subscriptions) | 1084 for (let subscription of subscriptions) |
1072 onSubscriptionMessage("added", subscription); | 1085 onSubscriptionMessage("added", subscription); |
| 1086 isSubscriptionsLoaded = true; |
1073 }); | 1087 }); |
1074 }); | 1088 }); |
1075 }); | 1089 }); |
1076 } | 1090 } |
1077 | 1091 |
1078 function addWhitelistedDomain() | 1092 function addWhitelistedDomain() |
1079 { | 1093 { |
1080 let domain = E("whitelisting-textbox"); | 1094 let domain = E("whitelisting-textbox"); |
1081 for (let whitelistItem of collections.whitelist.items) | 1095 for (let whitelistItem of collections.whitelist.items) |
1082 { | 1096 { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 updateSubscription(subscription); | 1178 updateSubscription(subscription); |
1165 break; | 1179 break; |
1166 case "downloading": | 1180 case "downloading": |
1167 case "downloadStatus": | 1181 case "downloadStatus": |
1168 case "homepage": | 1182 case "homepage": |
1169 case "lastDownload": | 1183 case "lastDownload": |
1170 case "title": | 1184 case "title": |
1171 updateSubscription(subscription); | 1185 updateSubscription(subscription); |
1172 break; | 1186 break; |
1173 case "added": | 1187 case "added": |
1174 if (subscription.url in subscriptionsMap) | 1188 let url = subscription.url; |
| 1189 if (url in subscriptionsMap) |
1175 updateSubscription(subscription); | 1190 updateSubscription(subscription); |
1176 else | 1191 else |
1177 addSubscription(subscription); | 1192 addSubscription(subscription); |
1178 | 1193 |
1179 if (isAcceptableAds(subscription.url)) | 1194 if (isAcceptableAds(url)) |
1180 setAcceptableAds(); | 1195 setAcceptableAds(); |
1181 | 1196 |
| 1197 if (url == acceptableAdsPrivacyUrl) |
| 1198 { |
| 1199 if (!navigator.doNotTrack) |
| 1200 setDntNotification(true); |
| 1201 } |
| 1202 |
| 1203 if (url == acceptableAdsUrl || subscription.recommended == "privacy") |
| 1204 { |
| 1205 if (isSubscriptionsLoaded && isPrivacyAndAdsEnabled()) |
| 1206 openDialog("tracking"); |
| 1207 } |
| 1208 |
1182 collections.filterLists.addItem(subscription); | 1209 collections.filterLists.addItem(subscription); |
1183 break; | 1210 break; |
1184 case "removed": | 1211 case "removed": |
1185 if (subscription.recommended) | 1212 if (subscription.recommended) |
1186 { | 1213 { |
1187 subscription.disabled = true; | 1214 subscription.disabled = true; |
1188 onSubscriptionMessage("disabled", subscription); | 1215 onSubscriptionMessage("disabled", subscription); |
1189 } | 1216 } |
1190 else | 1217 else |
1191 { | 1218 { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1332 }); | 1359 }); |
1333 ext.backgroundPage.sendMessage({ | 1360 ext.backgroundPage.sendMessage({ |
1334 type: "subscriptions.listen", | 1361 type: "subscriptions.listen", |
1335 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1362 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
1336 "title", "downloadStatus", "downloading"] | 1363 "title", "downloadStatus", "downloading"] |
1337 }); | 1364 }); |
1338 | 1365 |
1339 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1366 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
1340 window.addEventListener("hashchange", onHashChange, false); | 1367 window.addEventListener("hashchange", onHashChange, false); |
1341 } | 1368 } |
OLD | NEW |