| 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 11 matching lines...) Expand all Loading... |
| 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 {getMessage} = ext.i18n; | 30 let {getMessage} = ext.i18n; |
| 31 let customFilters = []; | 31 let customFilters = []; |
| 32 let showTrackingWarning = false; |
| 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", |
| 40 "options_filterList_lastDownload_checksumMismatch"] | 41 "options_filterList_lastDownload_checksumMismatch"] |
| 41 ]); | 42 ]); |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 type: "filters.importRaw", | 621 type: "filters.importRaw", |
| 621 text: E("custom-filters-raw").value, | 622 text: E("custom-filters-raw").value, |
| 622 removeExisting: true | 623 removeExisting: true |
| 623 }, | 624 }, |
| 624 () => | 625 () => |
| 625 { | 626 { |
| 626 setCustomFiltersView("read"); | 627 setCustomFiltersView("read"); |
| 627 }); | 628 }); |
| 628 break; | 629 break; |
| 629 case "switch-acceptable-ads": | 630 case "switch-acceptable-ads": |
| 630 let {value} = element; | 631 let value = element.value || element.dataset.value; |
| 631 ext.backgroundPage.sendMessage({ | 632 ext.backgroundPage.sendMessage({ |
| 632 type: value == "privacy" ? "subscriptions.add" : | 633 type: value == "privacy" ? "subscriptions.add" : |
| 633 "subscriptions.remove", | 634 "subscriptions.remove", |
| 634 url: acceptableAdsPrivacyUrl | 635 url: acceptableAdsPrivacyUrl |
| 635 }); | 636 }); |
| 636 ext.backgroundPage.sendMessage({ | 637 ext.backgroundPage.sendMessage({ |
| 637 type: value == "ads" ? "subscriptions.add" : "subscriptions.remove", | 638 type: value == "ads" ? "subscriptions.add" : "subscriptions.remove", |
| 638 url: acceptableAdsUrl | 639 url: acceptableAdsUrl |
| 639 }); | 640 }); |
| 640 break; | 641 break; |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 document.body.addEventListener("click", onClick, false); | 834 document.body.addEventListener("click", onClick, false); |
| 834 document.body.addEventListener("keyup", onKeyUp, false); | 835 document.body.addEventListener("keyup", onKeyUp, false); |
| 835 let exampleValue = getMessage("options_whitelist_placeholder_example", | 836 let exampleValue = getMessage("options_whitelist_placeholder_example", |
| 836 ["www.example.com"]); | 837 ["www.example.com"]); |
| 837 E("whitelisting-textbox").setAttribute("placeholder", exampleValue); | 838 E("whitelisting-textbox").setAttribute("placeholder", exampleValue); |
| 838 E("whitelisting-textbox").addEventListener("keyup", (e) => | 839 E("whitelisting-textbox").addEventListener("keyup", (e) => |
| 839 { | 840 { |
| 840 E("whitelisting-add-button").disabled = !e.target.value; | 841 E("whitelisting-add-button").disabled = !e.target.value; |
| 841 }, false); | 842 }, false); |
| 842 | 843 |
| 843 | 844 getPref("ui_warn_tracking", (value) => |
| 845 { |
| 846 showTrackingWarning = value; |
| 847 }); |
| 844 getDocLink("contribute", (link) => | 848 getDocLink("contribute", (link) => |
| 845 { | 849 { |
| 846 E("contribute").href = link; | 850 E("contribute").href = link; |
| 847 }); | 851 }); |
| 848 getDocLink("acceptable_ads_criteria", (link) => | 852 getDocLink("acceptable_ads_criteria", (link) => |
| 849 { | 853 { |
| 850 setLinks("enable-aa-description", link); | 854 setLinks("enable-aa-description", link); |
| 851 }); | 855 }); |
| 852 | 856 |
| 853 // Advanced tab | 857 // Advanced tab |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 document.forms["acceptable-ads"].classList.add("show-dnt-notification"); | 1006 document.forms["acceptable-ads"].classList.add("show-dnt-notification"); |
| 1003 } | 1007 } |
| 1004 document.forms["acceptable-ads"]["acceptable-ads"].value = option; | 1008 document.forms["acceptable-ads"]["acceptable-ads"].value = option; |
| 1005 } | 1009 } |
| 1006 | 1010 |
| 1007 function isAcceptableAds(url) | 1011 function isAcceptableAds(url) |
| 1008 { | 1012 { |
| 1009 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; | 1013 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; |
| 1010 } | 1014 } |
| 1011 | 1015 |
| 1016 function hasPrivacyConflict() |
| 1017 { |
| 1018 let acceptableAdsList = subscriptionsMap[acceptableAdsUrl]; |
| 1019 let privacyList = null; |
| 1020 for (let url in subscriptionsMap) |
| 1021 { |
| 1022 let subscription = subscriptionsMap[url]; |
| 1023 if (subscription.recommended == "privacy") |
| 1024 { |
| 1025 privacyList = subscription; |
| 1026 break; |
| 1027 } |
| 1028 } |
| 1029 return acceptableAdsList && acceptableAdsList.disabled == false && |
| 1030 privacyList && privacyList.disabled == false; |
| 1031 } |
| 1032 |
| 1012 function populateLists() | 1033 function populateLists() |
| 1013 { | 1034 { |
| 1014 subscriptionsMap = Object.create(null); | 1035 subscriptionsMap = Object.create(null); |
| 1015 filtersMap = Object.create(null); | 1036 filtersMap = Object.create(null); |
| 1016 | 1037 |
| 1017 // Empty collections and lists | 1038 // Empty collections and lists |
| 1018 for (let property in collections) | 1039 for (let property in collections) |
| 1019 collections[property].clearAll(); | 1040 collections[property].clearAll(); |
| 1020 | 1041 |
| 1021 ext.backgroundPage.sendMessage({ | 1042 ext.backgroundPage.sendMessage({ |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 updateSubscription(subscription); | 1186 updateSubscription(subscription); |
| 1166 break; | 1187 break; |
| 1167 case "downloading": | 1188 case "downloading": |
| 1168 case "downloadStatus": | 1189 case "downloadStatus": |
| 1169 case "homepage": | 1190 case "homepage": |
| 1170 case "lastDownload": | 1191 case "lastDownload": |
| 1171 case "title": | 1192 case "title": |
| 1172 updateSubscription(subscription); | 1193 updateSubscription(subscription); |
| 1173 break; | 1194 break; |
| 1174 case "added": | 1195 case "added": |
| 1175 if (subscription.url in subscriptionsMap) | 1196 let url = subscription.url; |
| 1197 if (url in subscriptionsMap) |
| 1176 updateSubscription(subscription); | 1198 updateSubscription(subscription); |
| 1177 else | 1199 else |
| 1178 addSubscription(subscription); | 1200 addSubscription(subscription); |
| 1179 | 1201 |
| 1180 if (isAcceptableAds(subscription.url)) | 1202 if (isAcceptableAds(url)) |
| 1181 setAcceptableAds(); | 1203 setAcceptableAds(); |
| 1182 | 1204 |
| 1205 if (url == acceptableAdsUrl || subscription.recommended == "privacy") |
| 1206 { |
| 1207 if (hasPrivacyConflict() && showTrackingWarning) |
| 1208 openDialog("tracking"); |
| 1209 } |
| 1210 |
| 1183 collections.filterLists.addItem(subscription); | 1211 collections.filterLists.addItem(subscription); |
| 1184 break; | 1212 break; |
| 1185 case "removed": | 1213 case "removed": |
| 1186 if (subscription.recommended) | 1214 if (subscription.recommended) |
| 1187 { | 1215 { |
| 1188 subscription.disabled = true; | 1216 subscription.disabled = true; |
| 1189 onSubscriptionMessage("disabled", subscription); | 1217 onSubscriptionMessage("disabled", subscription); |
| 1190 } | 1218 } |
| 1191 else | 1219 else |
| 1192 { | 1220 { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 { | 1276 { |
| 1249 switch (key) | 1277 switch (key) |
| 1250 { | 1278 { |
| 1251 case "notifications_ignoredcategories": | 1279 case "notifications_ignoredcategories": |
| 1252 value = value.indexOf("*") == -1; | 1280 value = value.indexOf("*") == -1; |
| 1253 break; | 1281 break; |
| 1254 | 1282 |
| 1255 case "notifications_showui": | 1283 case "notifications_showui": |
| 1256 hidePref("notifications_ignoredcategories", !value); | 1284 hidePref("notifications_ignoredcategories", !value); |
| 1257 break; | 1285 break; |
| 1286 |
| 1287 case "ui_warn_tracking": |
| 1288 showTrackingWarning = value; |
| 1289 break; |
| 1258 } | 1290 } |
| 1259 | 1291 |
| 1260 let checkbox = document.querySelector( | 1292 let checkbox = document.querySelector( |
| 1261 "[data-pref='" + key + "'] button[role='checkbox']" | 1293 "[data-pref='" + key + "'] button[role='checkbox']" |
| 1262 ); | 1294 ); |
| 1263 if (checkbox) | 1295 if (checkbox) |
| 1264 checkbox.setAttribute("aria-checked", value); | 1296 checkbox.setAttribute("aria-checked", value); |
| 1265 } | 1297 } |
| 1266 | 1298 |
| 1267 function updateTooltips() | 1299 function updateTooltips() |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1322 type: "app.listen", | 1354 type: "app.listen", |
| 1323 filter: ["addSubscription", "focusSection"] | 1355 filter: ["addSubscription", "focusSection"] |
| 1324 }); | 1356 }); |
| 1325 ext.backgroundPage.sendMessage({ | 1357 ext.backgroundPage.sendMessage({ |
| 1326 type: "filters.listen", | 1358 type: "filters.listen", |
| 1327 filter: ["added", "loaded", "removed"] | 1359 filter: ["added", "loaded", "removed"] |
| 1328 }); | 1360 }); |
| 1329 ext.backgroundPage.sendMessage({ | 1361 ext.backgroundPage.sendMessage({ |
| 1330 type: "prefs.listen", | 1362 type: "prefs.listen", |
| 1331 filter: ["notifications_ignoredcategories", "notifications_showui", | 1363 filter: ["notifications_ignoredcategories", "notifications_showui", |
| 1332 "show_devtools_panel", "shouldShowBlockElementMenu"] | 1364 "show_devtools_panel", "shouldShowBlockElementMenu", |
| 1365 "ui_warn_tracking"] |
| 1333 }); | 1366 }); |
| 1334 ext.backgroundPage.sendMessage({ | 1367 ext.backgroundPage.sendMessage({ |
| 1335 type: "subscriptions.listen", | 1368 type: "subscriptions.listen", |
| 1336 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1369 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
| 1337 "title", "downloadStatus", "downloading"] | 1370 "title", "downloadStatus", "downloading"] |
| 1338 }); | 1371 }); |
| 1339 | 1372 |
| 1340 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1373 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
| 1341 window.addEventListener("hashchange", onHashChange, false); | 1374 window.addEventListener("hashchange", onHashChange, false); |
| 1342 } | 1375 } |
| OLD | NEW |