| LEFT | RIGHT |
| 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 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 }); | 943 }); |
| 944 | 944 |
| 945 // Advanced tab | 945 // Advanced tab |
| 946 let customize = document.querySelectorAll("#customize li[data-pref]"); | 946 let customize = document.querySelectorAll("#customize li[data-pref]"); |
| 947 customize = Array.prototype.map.call(customize, (checkbox) => | 947 customize = Array.prototype.map.call(customize, (checkbox) => |
| 948 { | 948 { |
| 949 return checkbox.getAttribute("data-pref"); | 949 return checkbox.getAttribute("data-pref"); |
| 950 }); | 950 }); |
| 951 for (let key of customize) | 951 for (let key of customize) |
| 952 { | 952 { |
| 953 getHidePref(key, (value) => | 953 getPref(key, (value) => |
| 954 { | 954 { |
| 955 onPrefMessage(key, value, true); | 955 onPrefMessage(key, value, true); |
| 956 }); | 956 }); |
| 957 } | 957 } |
| 958 browser.runtime.sendMessage({ | 958 browser.runtime.sendMessage({ |
| 959 type: "app.get", | 959 type: "app.get", |
| 960 what: "features" | 960 what: "features" |
| 961 }, | 961 }, |
| 962 (features) => | 962 (features) => |
| 963 { | 963 { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1123 } | 1123 } |
| 1124 return acceptableAdsList && acceptableAdsList.disabled == false && | 1124 return acceptableAdsList && acceptableAdsList.disabled == false && |
| 1125 privacyList && privacyList.disabled == false; | 1125 privacyList && privacyList.disabled == false; |
| 1126 } | 1126 } |
| 1127 | 1127 |
| 1128 function setPrivacyConflict() | 1128 function setPrivacyConflict() |
| 1129 { | 1129 { |
| 1130 let acceptableAdsForm = E("acceptable-ads"); | 1130 let acceptableAdsForm = E("acceptable-ads"); |
| 1131 if (hasPrivacyConflict()) | 1131 if (hasPrivacyConflict()) |
| 1132 { | 1132 { |
| 1133 getHidePref("ui_warn_tracking", (showTrackingWarning) => | 1133 getPref("ui_warn_tracking", (showTrackingWarning) => |
| 1134 { | 1134 { |
| 1135 acceptableAdsForm.classList.toggle("show-warning", showTrackingWarning); | 1135 acceptableAdsForm.classList.toggle("show-warning", showTrackingWarning); |
| 1136 }); | 1136 }); |
| 1137 } | 1137 } |
| 1138 else | 1138 else |
| 1139 { | 1139 { |
| 1140 acceptableAdsForm.classList.remove("show-warning"); | 1140 acceptableAdsForm.classList.remove("show-warning"); |
| 1141 } | 1141 } |
| 1142 } | 1142 } |
| 1143 | 1143 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1158 (subscriptions) => | 1158 (subscriptions) => |
| 1159 { | 1159 { |
| 1160 let customFilterPromises = subscriptions.map(getSubscriptionFilters); | 1160 let customFilterPromises = subscriptions.map(getSubscriptionFilters); |
| 1161 Promise.all(customFilterPromises).then((filters) => | 1161 Promise.all(customFilterPromises).then((filters) => |
| 1162 { | 1162 { |
| 1163 loadCustomFilters([].concat(...filters)); | 1163 loadCustomFilters([].concat(...filters)); |
| 1164 isCustomFiltersLoaded = true; | 1164 isCustomFiltersLoaded = true; |
| 1165 }); | 1165 }); |
| 1166 }); | 1166 }); |
| 1167 loadRecommendations(); | 1167 loadRecommendations(); |
| 1168 let preloadPrefs = ["subscriptions_exceptionsurl", | 1168 browser.runtime.sendMessage({ |
| 1169 "subscriptions_exceptionsurl_privacy", | 1169 type: "prefs.get", |
| 1170 "additional_subscriptions"]; | 1170 key: "subscriptions_exceptionsurl" |
| 1171 getPrefs(preloadPrefs).then(prefs => | 1171 }, |
| 1172 { | 1172 (url) => |
| 1173 [acceptableAdsUrl, acceptableAdsPrivacyUrl, | 1173 { |
| 1174 additionalSubscriptions] = prefs; | 1174 acceptableAdsUrl = url; |
| 1175 | 1175 |
| 1176 return browser.runtime.sendMessage({ | 1176 browser.runtime.sendMessage({ |
| 1177 type: "subscriptions.get", | 1177 type: "prefs.get", |
| 1178 downloadable: true | 1178 key: "subscriptions_exceptionsurl_privacy" |
| 1179 }, |
| 1180 (urlPrivacy) => |
| 1181 { |
| 1182 acceptableAdsPrivacyUrl = urlPrivacy; |
| 1183 |
| 1184 getPref("additional_subscriptions", (subscriptionUrls) => |
| 1185 { |
| 1186 additionalSubscriptions = subscriptionUrls; |
| 1187 |
| 1188 // Load user subscriptions |
| 1189 browser.runtime.sendMessage({ |
| 1190 type: "subscriptions.get", |
| 1191 downloadable: true |
| 1192 }, |
| 1193 (subscriptions) => |
| 1194 { |
| 1195 for (let subscription of subscriptions) |
| 1196 onSubscriptionMessage("added", subscription); |
| 1197 |
| 1198 setAcceptableAds(); |
| 1199 }); |
| 1200 }); |
| 1179 }); | 1201 }); |
| 1180 }).then((subscriptions) => | |
| 1181 { | |
| 1182 for (let subscription of subscriptions) | |
| 1183 onSubscriptionMessage("added", subscription); | |
| 1184 | |
| 1185 setAcceptableAds(); | |
| 1186 }); | 1202 }); |
| 1187 } | 1203 } |
| 1188 | 1204 |
| 1189 function addWhitelistedDomain() | 1205 function addWhitelistedDomain() |
| 1190 { | 1206 { |
| 1191 let domain = E("whitelisting-textbox"); | 1207 let domain = E("whitelisting-textbox"); |
| 1192 for (let whitelistItem of collections.whitelist.items) | 1208 for (let whitelistItem of collections.whitelist.items) |
| 1193 { | 1209 { |
| 1194 if (whitelistItem.title == domain.value) | 1210 if (whitelistItem.title == domain.value) |
| 1195 { | 1211 { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1335 subscriptionUrl: subscription.url}); | 1351 subscriptionUrl: subscription.url}); |
| 1336 } | 1352 } |
| 1337 | 1353 |
| 1338 function hidePref(key, value) | 1354 function hidePref(key, value) |
| 1339 { | 1355 { |
| 1340 let element = document.querySelector("[data-pref='" + key + "']"); | 1356 let element = document.querySelector("[data-pref='" + key + "']"); |
| 1341 if (element) | 1357 if (element) |
| 1342 element.setAttribute("aria-hidden", value); | 1358 element.setAttribute("aria-hidden", value); |
| 1343 } | 1359 } |
| 1344 | 1360 |
| 1345 function getPrefs(prefKeys) | 1361 function getPref(key, callback) |
| 1346 { | 1362 { |
| 1347 prefKeys = prefKeys.map(key => browser.runtime.sendMessage({ | 1363 let checkPref = getPref.checks[key] || getPref.checkNone; |
| 1348 type: "prefs.get", key | |
| 1349 })); | |
| 1350 return Promise.all(prefKeys); | |
| 1351 } | |
| 1352 | |
| 1353 function getHidePref(key, callback) | |
| 1354 { | |
| 1355 let checkPref = getHidePref.checks[key] || getHidePref.checkNone; | |
| 1356 checkPref((isActive) => | 1364 checkPref((isActive) => |
| 1357 { | 1365 { |
| 1358 if (!isActive) | 1366 if (!isActive) |
| 1359 { | 1367 { |
| 1360 hidePref(key, !isActive); | 1368 hidePref(key, !isActive); |
| 1361 return; | 1369 return; |
| 1362 } | 1370 } |
| 1363 | 1371 |
| 1364 browser.runtime.sendMessage({ | 1372 browser.runtime.sendMessage({ |
| 1365 type: "prefs.get", | 1373 type: "prefs.get", |
| 1366 key | 1374 key |
| 1367 }, callback); | 1375 }, callback); |
| 1368 }); | 1376 }); |
| 1369 } | 1377 } |
| 1370 | 1378 |
| 1371 getHidePref.checkNone = function(callback) | 1379 getPref.checkNone = function(callback) |
| 1372 { | 1380 { |
| 1373 callback(true); | 1381 callback(true); |
| 1374 }; | 1382 }; |
| 1375 | 1383 |
| 1376 getHidePref.checks = | 1384 getPref.checks = |
| 1377 { | 1385 { |
| 1378 notifications_ignoredcategories(callback) | 1386 notifications_ignoredcategories(callback) |
| 1379 { | 1387 { |
| 1380 getHidePref("notifications_showui", callback); | 1388 getPref("notifications_showui", callback); |
| 1381 } | 1389 } |
| 1382 }; | 1390 }; |
| 1383 | 1391 |
| 1384 function onPrefMessage(key, value, initial) | 1392 function onPrefMessage(key, value, initial) |
| 1385 { | 1393 { |
| 1386 switch (key) | 1394 switch (key) |
| 1387 { | 1395 { |
| 1388 case "notifications_ignoredcategories": | 1396 case "notifications_ignoredcategories": |
| 1389 value = value.indexOf("*") == -1; | 1397 value = value.indexOf("*") == -1; |
| 1390 break; | 1398 break; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1473 "ui_warn_tracking"] | 1481 "ui_warn_tracking"] |
| 1474 }); | 1482 }); |
| 1475 browser.runtime.sendMessage({ | 1483 browser.runtime.sendMessage({ |
| 1476 type: "subscriptions.listen", | 1484 type: "subscriptions.listen", |
| 1477 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1485 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
| 1478 "title", "downloadStatus", "downloading"] | 1486 "title", "downloadStatus", "downloading"] |
| 1479 }); | 1487 }); |
| 1480 | 1488 |
| 1481 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1489 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
| 1482 window.addEventListener("hashchange", onHashChange, false); | 1490 window.addEventListener("hashchange", onHashChange, false); |
| LEFT | RIGHT |