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 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 if (subscription.recommended == "privacy") | 1111 if (subscription.recommended == "privacy") |
1112 { | 1112 { |
1113 privacyList = subscription; | 1113 privacyList = subscription; |
1114 break; | 1114 break; |
1115 } | 1115 } |
1116 } | 1116 } |
1117 return acceptableAdsList && acceptableAdsList.disabled == false && | 1117 return acceptableAdsList && acceptableAdsList.disabled == false && |
1118 privacyList && privacyList.disabled == false; | 1118 privacyList && privacyList.disabled == false; |
1119 } | 1119 } |
1120 | 1120 |
| 1121 function setPrivacyConflict() |
| 1122 { |
| 1123 let acceptableAdsForm = E("acceptable-ads"); |
| 1124 if (hasPrivacyConflict()) |
| 1125 { |
| 1126 getPref("ui_warn_tracking", (showTrackingWarning) => |
| 1127 { |
| 1128 acceptableAdsForm.classList.toggle("show-warning", showTrackingWarning); |
| 1129 }); |
| 1130 } |
| 1131 else |
| 1132 { |
| 1133 acceptableAdsForm.classList.remove("show-warning"); |
| 1134 } |
| 1135 } |
| 1136 |
1121 function populateLists() | 1137 function populateLists() |
1122 { | 1138 { |
1123 subscriptionsMap = Object.create(null); | 1139 subscriptionsMap = Object.create(null); |
1124 filtersMap = Object.create(null); | 1140 filtersMap = Object.create(null); |
1125 | 1141 |
1126 // Empty collections and lists | 1142 // Empty collections and lists |
1127 for (let property in collections) | 1143 for (let property in collections) |
1128 collections[property].clearAll(); | 1144 collections[property].clearAll(); |
1129 | 1145 |
1130 setCustomFiltersView("empty"); | 1146 setCustomFiltersView("empty"); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1260 knownSubscription.originalTitle = subscription.title; | 1276 knownSubscription.originalTitle = subscription.title; |
1261 else | 1277 else |
1262 knownSubscription[property] = subscription[property]; | 1278 knownSubscription[property] = subscription[property]; |
1263 } | 1279 } |
1264 subscription = knownSubscription; | 1280 subscription = knownSubscription; |
1265 } | 1281 } |
1266 switch (action) | 1282 switch (action) |
1267 { | 1283 { |
1268 case "disabled": | 1284 case "disabled": |
1269 updateSubscription(subscription); | 1285 updateSubscription(subscription); |
| 1286 setPrivacyConflict(); |
1270 break; | 1287 break; |
1271 case "downloading": | 1288 case "downloading": |
1272 case "downloadStatus": | 1289 case "downloadStatus": |
1273 case "homepage": | 1290 case "homepage": |
1274 case "lastDownload": | 1291 case "lastDownload": |
1275 case "title": | 1292 case "title": |
1276 updateSubscription(subscription); | 1293 updateSubscription(subscription); |
1277 break; | 1294 break; |
1278 case "added": | 1295 case "added": |
1279 let {url, recommended} = subscription; | 1296 let {url, recommended} = subscription; |
1280 // Handle custom subscription | 1297 // Handle custom subscription |
1281 if (/^~user/.test(url)) | 1298 if (/^~user/.test(url)) |
1282 { | 1299 { |
1283 loadCustomFilters(subscription.filters); | 1300 loadCustomFilters(subscription.filters); |
1284 return; | 1301 return; |
1285 } | 1302 } |
1286 else if (url in subscriptionsMap) | 1303 else if (url in subscriptionsMap) |
1287 updateSubscription(subscription); | 1304 updateSubscription(subscription); |
1288 else | 1305 else |
1289 addSubscription(subscription); | 1306 addSubscription(subscription); |
1290 | 1307 |
1291 if (isAcceptableAds(url)) | 1308 if (isAcceptableAds(url)) |
1292 setAcceptableAds(); | 1309 setAcceptableAds(); |
1293 | 1310 |
1294 if ((url == acceptableAdsUrl || recommended == "privacy") && | |
1295 hasPrivacyConflict()) | |
1296 { | |
1297 getPref("ui_warn_tracking", (showTrackingWarning) => | |
1298 { | |
1299 if (showTrackingWarning) | |
1300 E("acceptable-ads").classList.add("show-warning"); | |
1301 }); | |
1302 } | |
1303 | |
1304 collections.filterLists.addItem(subscription); | 1311 collections.filterLists.addItem(subscription); |
| 1312 setPrivacyConflict(); |
1305 break; | 1313 break; |
1306 case "removed": | 1314 case "removed": |
1307 if (subscription.recommended) | 1315 if (subscription.recommended) |
1308 { | 1316 { |
1309 subscription.disabled = true; | 1317 subscription.disabled = true; |
1310 onSubscriptionMessage("disabled", subscription); | 1318 onSubscriptionMessage("disabled", subscription); |
1311 } | 1319 } |
1312 else | 1320 else |
1313 { | 1321 { |
1314 delete subscriptionsMap[subscription.url]; | 1322 delete subscriptionsMap[subscription.url]; |
1315 if (isAcceptableAds(subscription.url)) | 1323 if (isAcceptableAds(subscription.url)) |
1316 { | 1324 { |
1317 setAcceptableAds(); | 1325 setAcceptableAds(); |
1318 } | 1326 } |
1319 else | 1327 else |
1320 { | 1328 { |
1321 collections.more.removeItem(subscription); | 1329 collections.more.removeItem(subscription); |
1322 } | 1330 } |
1323 } | 1331 } |
| 1332 |
1324 collections.filterLists.removeItem(subscription); | 1333 collections.filterLists.removeItem(subscription); |
| 1334 setPrivacyConflict(); |
1325 break; | 1335 break; |
1326 } | 1336 } |
1327 } | 1337 } |
1328 | 1338 |
1329 function hidePref(key, value) | 1339 function hidePref(key, value) |
1330 { | 1340 { |
1331 let element = document.querySelector("[data-pref='" + key + "']"); | 1341 let element = document.querySelector("[data-pref='" + key + "']"); |
1332 if (element) | 1342 if (element) |
1333 element.setAttribute("aria-hidden", value); | 1343 element.setAttribute("aria-hidden", value); |
1334 } | 1344 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1369 switch (key) | 1379 switch (key) |
1370 { | 1380 { |
1371 case "notifications_ignoredcategories": | 1381 case "notifications_ignoredcategories": |
1372 value = value.indexOf("*") == -1; | 1382 value = value.indexOf("*") == -1; |
1373 break; | 1383 break; |
1374 | 1384 |
1375 case "notifications_showui": | 1385 case "notifications_showui": |
1376 hidePref("notifications_ignoredcategories", !value); | 1386 hidePref("notifications_ignoredcategories", !value); |
1377 break; | 1387 break; |
1378 case "ui_warn_tracking": | 1388 case "ui_warn_tracking": |
1379 let showWarning = (value && hasPrivacyConflict()); | 1389 setPrivacyConflict(); |
1380 E("acceptable-ads").classList.toggle("show-warning", showWarning); | |
1381 break; | 1390 break; |
1382 } | 1391 } |
1383 | 1392 |
1384 let checkbox = document.querySelector( | 1393 let checkbox = document.querySelector( |
1385 "[data-pref='" + key + "'] button[role='checkbox']" | 1394 "[data-pref='" + key + "'] button[role='checkbox']" |
1386 ); | 1395 ); |
1387 if (checkbox) | 1396 if (checkbox) |
1388 checkbox.setAttribute("aria-checked", value); | 1397 checkbox.setAttribute("aria-checked", value); |
1389 } | 1398 } |
1390 | 1399 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1458 }); | 1467 }); |
1459 browser.runtime.sendMessage({ | 1468 browser.runtime.sendMessage({ |
1460 type: "subscriptions.listen", | 1469 type: "subscriptions.listen", |
1461 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1470 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
1462 "title", "downloadStatus", "downloading"] | 1471 "title", "downloadStatus", "downloading"] |
1463 }); | 1472 }); |
1464 | 1473 |
1465 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1474 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
1466 window.addEventListener("hashchange", onHashChange, false); | 1475 window.addEventListener("hashchange", onHashChange, false); |
1467 } | 1476 } |
OLD | NEW |