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