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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 ]); | 365 ]); |
366 collections.filterLists = new Collection([ | 366 collections.filterLists = new Collection([ |
367 { | 367 { |
368 id: "all-filter-lists-table", | 368 id: "all-filter-lists-table", |
369 useOriginalTitle: true | 369 useOriginalTitle: true |
370 } | 370 } |
371 ]); | 371 ]); |
372 | 372 |
373 function addSubscription(subscription) | 373 function addSubscription(subscription) |
374 { | 374 { |
375 let disabled = subscription.disabled; | 375 let {disabled} = subscription; |
376 let collection = null; | 376 let collection = null; |
377 if (subscription.recommended) | 377 if (subscription.recommended) |
378 { | 378 { |
379 if (subscription.recommended == "ads") | 379 if (subscription.recommended == "ads") |
380 { | 380 { |
381 if (disabled == false) | 381 if (disabled == false) |
382 collection = collections.langs; | 382 collection = collections.langs; |
383 | 383 |
384 collections.allLangs.addItem(subscription); | 384 collections.allLangs.addItem(subscription); |
385 } | 385 } |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 type: "filters.importRaw", | 620 type: "filters.importRaw", |
621 text: E("custom-filters-raw").value, | 621 text: E("custom-filters-raw").value, |
622 removeExisting: true | 622 removeExisting: true |
623 }, | 623 }, |
624 () => | 624 () => |
625 { | 625 { |
626 setCustomFiltersView("read"); | 626 setCustomFiltersView("read"); |
627 }); | 627 }); |
628 break; | 628 break; |
629 case "switch-acceptable-ads": | 629 case "switch-acceptable-ads": |
630 let {value} = element; | 630 let value = element.value || element.dataset.value; |
631 ext.backgroundPage.sendMessage({ | 631 ext.backgroundPage.sendMessage({ |
632 type: value == "privacy" ? "subscriptions.add" : | 632 type: value == "privacy" ? "subscriptions.add" : |
633 "subscriptions.remove", | 633 "subscriptions.remove", |
634 url: acceptableAdsPrivacyUrl | 634 url: acceptableAdsPrivacyUrl |
635 }); | 635 }); |
636 ext.backgroundPage.sendMessage({ | 636 ext.backgroundPage.sendMessage({ |
637 type: value == "ads" ? "subscriptions.add" : "subscriptions.remove", | 637 type: value == "ads" ? "subscriptions.add" : "subscriptions.remove", |
638 url: acceptableAdsUrl | 638 url: acceptableAdsUrl |
639 }); | 639 }); |
640 break; | 640 break; |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 document.body.addEventListener("click", onClick, false); | 850 document.body.addEventListener("click", onClick, false); |
851 document.body.addEventListener("keyup", onKeyUp, false); | 851 document.body.addEventListener("keyup", onKeyUp, false); |
852 let exampleValue = getMessage("options_whitelist_placeholder_example", | 852 let exampleValue = getMessage("options_whitelist_placeholder_example", |
853 ["www.example.com"]); | 853 ["www.example.com"]); |
854 E("whitelisting-textbox").setAttribute("placeholder", exampleValue); | 854 E("whitelisting-textbox").setAttribute("placeholder", exampleValue); |
855 E("whitelisting-textbox").addEventListener("keyup", (e) => | 855 E("whitelisting-textbox").addEventListener("keyup", (e) => |
856 { | 856 { |
857 E("whitelisting-add-button").disabled = !e.target.value; | 857 E("whitelisting-add-button").disabled = !e.target.value; |
858 }, false); | 858 }, false); |
859 | 859 |
860 | |
861 getDocLink("contribute", (link) => | 860 getDocLink("contribute", (link) => |
862 { | 861 { |
863 E("contribute").href = link; | 862 E("contribute").href = link; |
864 }); | 863 }); |
865 getDocLink("acceptable_ads_criteria", (link) => | 864 getDocLink("acceptable_ads_criteria", (link) => |
866 { | 865 { |
867 setLinks("enable-aa-description", link); | 866 setLinks("enable-aa-description", link); |
868 }); | 867 }); |
869 | 868 |
870 // Advanced tab | 869 // Advanced tab |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 document.forms["acceptable-ads"].classList.add("show-dnt-notification"); | 1018 document.forms["acceptable-ads"].classList.add("show-dnt-notification"); |
1020 } | 1019 } |
1021 document.forms["acceptable-ads"]["acceptable-ads"].value = option; | 1020 document.forms["acceptable-ads"]["acceptable-ads"].value = option; |
1022 } | 1021 } |
1023 | 1022 |
1024 function isAcceptableAds(url) | 1023 function isAcceptableAds(url) |
1025 { | 1024 { |
1026 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; | 1025 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; |
1027 } | 1026 } |
1028 | 1027 |
| 1028 function hasPrivacyConflict() |
| 1029 { |
| 1030 let acceptableAdsList = subscriptionsMap[acceptableAdsUrl]; |
| 1031 let privacyList = null; |
| 1032 for (let url in subscriptionsMap) |
| 1033 { |
| 1034 let subscription = subscriptionsMap[url]; |
| 1035 if (subscription.recommended == "privacy") |
| 1036 { |
| 1037 privacyList = subscription; |
| 1038 break; |
| 1039 } |
| 1040 } |
| 1041 return acceptableAdsList && acceptableAdsList.disabled == false && |
| 1042 privacyList && privacyList.disabled == false; |
| 1043 } |
| 1044 |
1029 function populateLists() | 1045 function populateLists() |
1030 { | 1046 { |
1031 subscriptionsMap = Object.create(null); | 1047 subscriptionsMap = Object.create(null); |
1032 filtersMap = Object.create(null); | 1048 filtersMap = Object.create(null); |
1033 | 1049 |
1034 // Empty collections and lists | 1050 // Empty collections and lists |
1035 for (let property in collections) | 1051 for (let property in collections) |
1036 collections[property].clearAll(); | 1052 collections[property].clearAll(); |
1037 | 1053 |
1038 ext.backgroundPage.sendMessage({ | 1054 ext.backgroundPage.sendMessage({ |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 updateSubscription(subscription); | 1198 updateSubscription(subscription); |
1183 break; | 1199 break; |
1184 case "downloading": | 1200 case "downloading": |
1185 case "downloadStatus": | 1201 case "downloadStatus": |
1186 case "homepage": | 1202 case "homepage": |
1187 case "lastDownload": | 1203 case "lastDownload": |
1188 case "title": | 1204 case "title": |
1189 updateSubscription(subscription); | 1205 updateSubscription(subscription); |
1190 break; | 1206 break; |
1191 case "added": | 1207 case "added": |
1192 if (subscription.url in subscriptionsMap) | 1208 let {url, recommended} = subscription; |
| 1209 if (url in subscriptionsMap) |
1193 updateSubscription(subscription); | 1210 updateSubscription(subscription); |
1194 else | 1211 else |
1195 addSubscription(subscription); | 1212 addSubscription(subscription); |
1196 | 1213 |
1197 if (isAcceptableAds(subscription.url)) | 1214 if (isAcceptableAds(url)) |
1198 setAcceptableAds(); | 1215 setAcceptableAds(); |
1199 | 1216 |
| 1217 if ((url == acceptableAdsUrl || recommended == "privacy") && |
| 1218 hasPrivacyConflict()) |
| 1219 { |
| 1220 getPref("ui_warn_tracking", (showTrackingWarning) => |
| 1221 { |
| 1222 if (showTrackingWarning) |
| 1223 openDialog("tracking"); |
| 1224 }); |
| 1225 } |
| 1226 |
1200 collections.filterLists.addItem(subscription); | 1227 collections.filterLists.addItem(subscription); |
1201 break; | 1228 break; |
1202 case "removed": | 1229 case "removed": |
1203 if (subscription.recommended) | 1230 if (subscription.recommended) |
1204 { | 1231 { |
1205 subscription.disabled = true; | 1232 subscription.disabled = true; |
1206 onSubscriptionMessage("disabled", subscription); | 1233 onSubscriptionMessage("disabled", subscription); |
1207 } | 1234 } |
1208 else | 1235 else |
1209 { | 1236 { |
1210 delete subscriptionsMap[subscription.url]; | 1237 delete subscriptionsMap[subscription.url]; |
1211 if (isAcceptableAds(subscription.url)) | 1238 if (isAcceptableAds(subscription.url)) |
1212 { | 1239 { |
1213 setAcceptableAds(); | 1240 setAcceptableAds(); |
1214 } | 1241 } |
1215 else | 1242 else |
1216 { | 1243 { |
1217 collections.more.removeItem(subscription); | 1244 collections.more.removeItem(subscription); |
1218 } | 1245 } |
1219 } | 1246 } |
1220 collections.filterLists.removeItem(subscription); | 1247 collections.filterLists.removeItem(subscription); |
1221 break; | 1248 break; |
1222 } | 1249 } |
1223 | |
1224 } | 1250 } |
1225 | 1251 |
1226 function hidePref(key, value) | 1252 function hidePref(key, value) |
1227 { | 1253 { |
1228 let element = document.querySelector("[data-pref='" + key + "']"); | 1254 let element = document.querySelector("[data-pref='" + key + "']"); |
1229 if (element) | 1255 if (element) |
1230 element.setAttribute("aria-hidden", value); | 1256 element.setAttribute("aria-hidden", value); |
1231 } | 1257 } |
1232 | 1258 |
1233 function getPref(key, callback) | 1259 function getPref(key, callback) |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1339 type: "app.listen", | 1365 type: "app.listen", |
1340 filter: ["addSubscription", "focusSection"] | 1366 filter: ["addSubscription", "focusSection"] |
1341 }); | 1367 }); |
1342 ext.backgroundPage.sendMessage({ | 1368 ext.backgroundPage.sendMessage({ |
1343 type: "filters.listen", | 1369 type: "filters.listen", |
1344 filter: ["added", "loaded", "removed"] | 1370 filter: ["added", "loaded", "removed"] |
1345 }); | 1371 }); |
1346 ext.backgroundPage.sendMessage({ | 1372 ext.backgroundPage.sendMessage({ |
1347 type: "prefs.listen", | 1373 type: "prefs.listen", |
1348 filter: ["notifications_ignoredcategories", "notifications_showui", | 1374 filter: ["notifications_ignoredcategories", "notifications_showui", |
1349 "show_devtools_panel", "shouldShowBlockElementMenu"] | 1375 "show_devtools_panel", "shouldShowBlockElementMenu", |
| 1376 "ui_warn_tracking"] |
1350 }); | 1377 }); |
1351 ext.backgroundPage.sendMessage({ | 1378 ext.backgroundPage.sendMessage({ |
1352 type: "subscriptions.listen", | 1379 type: "subscriptions.listen", |
1353 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1380 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
1354 "title", "downloadStatus", "downloading"] | 1381 "title", "downloadStatus", "downloading"] |
1355 }); | 1382 }); |
1356 | 1383 |
1357 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1384 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
1358 window.addEventListener("hashchange", onHashChange, false); | 1385 window.addEventListener("hashchange", onHashChange, false); |
1359 } | 1386 } |
OLD | NEW |