| 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 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; |
|
saroyanm
2017/09/21 15:50:40
Note: This is part of eslint error fix. I fixed co
| |
| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 833 document.body.addEventListener("click", onClick, false); | 833 document.body.addEventListener("click", onClick, false); |
| 834 document.body.addEventListener("keyup", onKeyUp, false); | 834 document.body.addEventListener("keyup", onKeyUp, false); |
| 835 let exampleValue = getMessage("options_whitelist_placeholder_example", | 835 let exampleValue = getMessage("options_whitelist_placeholder_example", |
| 836 ["www.example.com"]); | 836 ["www.example.com"]); |
| 837 E("whitelisting-textbox").setAttribute("placeholder", exampleValue); | 837 E("whitelisting-textbox").setAttribute("placeholder", exampleValue); |
| 838 E("whitelisting-textbox").addEventListener("keyup", (e) => | 838 E("whitelisting-textbox").addEventListener("keyup", (e) => |
| 839 { | 839 { |
| 840 E("whitelisting-add-button").disabled = !e.target.value; | 840 E("whitelisting-add-button").disabled = !e.target.value; |
| 841 }, false); | 841 }, false); |
| 842 | 842 |
| 843 | |
| 844 getDocLink("contribute", (link) => | 843 getDocLink("contribute", (link) => |
| 845 { | 844 { |
| 846 E("contribute").href = link; | 845 E("contribute").href = link; |
| 847 }); | 846 }); |
| 848 getDocLink("acceptable_ads_criteria", (link) => | 847 getDocLink("acceptable_ads_criteria", (link) => |
| 849 { | 848 { |
| 850 setLinks("enable-aa-description", link); | 849 setLinks("enable-aa-description", link); |
| 851 }); | 850 }); |
| 852 | 851 |
| 853 // Advanced tab | 852 // 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"); | 1001 document.forms["acceptable-ads"].classList.add("show-dnt-notification"); |
| 1003 } | 1002 } |
| 1004 document.forms["acceptable-ads"]["acceptable-ads"].value = option; | 1003 document.forms["acceptable-ads"]["acceptable-ads"].value = option; |
| 1005 } | 1004 } |
| 1006 | 1005 |
| 1007 function isAcceptableAds(url) | 1006 function isAcceptableAds(url) |
| 1008 { | 1007 { |
| 1009 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; | 1008 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; |
| 1010 } | 1009 } |
| 1011 | 1010 |
| 1011 function hasPrivacyConflict() | |
| 1012 { | |
| 1013 let acceptableAdsList = subscriptionsMap[acceptableAdsUrl]; | |
| 1014 let privacyList = null; | |
| 1015 for (let url in subscriptionsMap) | |
| 1016 { | |
| 1017 let subscription = subscriptionsMap[url]; | |
| 1018 if (subscription.recommended == "privacy") | |
| 1019 { | |
| 1020 privacyList = subscription; | |
| 1021 break; | |
| 1022 } | |
| 1023 } | |
| 1024 return acceptableAdsList && acceptableAdsList.disabled == false && | |
| 1025 privacyList && privacyList.disabled == false; | |
| 1026 } | |
| 1027 | |
| 1012 function populateLists() | 1028 function populateLists() |
| 1013 { | 1029 { |
| 1014 subscriptionsMap = Object.create(null); | 1030 subscriptionsMap = Object.create(null); |
| 1015 filtersMap = Object.create(null); | 1031 filtersMap = Object.create(null); |
| 1016 | 1032 |
| 1017 // Empty collections and lists | 1033 // Empty collections and lists |
| 1018 for (let property in collections) | 1034 for (let property in collections) |
| 1019 collections[property].clearAll(); | 1035 collections[property].clearAll(); |
| 1020 | 1036 |
| 1021 ext.backgroundPage.sendMessage({ | 1037 ext.backgroundPage.sendMessage({ |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1165 updateSubscription(subscription); | 1181 updateSubscription(subscription); |
| 1166 break; | 1182 break; |
| 1167 case "downloading": | 1183 case "downloading": |
| 1168 case "downloadStatus": | 1184 case "downloadStatus": |
| 1169 case "homepage": | 1185 case "homepage": |
| 1170 case "lastDownload": | 1186 case "lastDownload": |
| 1171 case "title": | 1187 case "title": |
| 1172 updateSubscription(subscription); | 1188 updateSubscription(subscription); |
| 1173 break; | 1189 break; |
| 1174 case "added": | 1190 case "added": |
| 1175 if (subscription.url in subscriptionsMap) | 1191 let {url} = subscription; |
| 1192 if (url in subscriptionsMap) | |
| 1176 updateSubscription(subscription); | 1193 updateSubscription(subscription); |
| 1177 else | 1194 else |
| 1178 addSubscription(subscription); | 1195 addSubscription(subscription); |
| 1179 | 1196 |
| 1180 if (isAcceptableAds(subscription.url)) | 1197 if (isAcceptableAds(url)) |
| 1181 setAcceptableAds(); | 1198 setAcceptableAds(); |
| 1182 | 1199 |
| 1200 if (url == acceptableAdsUrl || subscription.recommended == "privacy") | |
| 1201 { | |
| 1202 getPref("ui_warn_tracking", (showTrackingWarning) => | |
|
saroyanm
2017/09/21 15:50:40
I'm not sure if using promise is better in this ca
Thomas Greiner
2017/09/22 10:05:43
Using a promise you could've avoided making that r
saroyanm
2017/09/22 10:33:23
I agree, done.
| |
| 1203 { | |
| 1204 if (hasPrivacyConflict() && showTrackingWarning) | |
| 1205 openDialog("tracking"); | |
| 1206 }); | |
| 1207 } | |
| 1208 | |
| 1183 collections.filterLists.addItem(subscription); | 1209 collections.filterLists.addItem(subscription); |
| 1184 break; | 1210 break; |
| 1185 case "removed": | 1211 case "removed": |
| 1186 if (subscription.recommended) | 1212 if (subscription.recommended) |
| 1187 { | 1213 { |
| 1188 subscription.disabled = true; | 1214 subscription.disabled = true; |
| 1189 onSubscriptionMessage("disabled", subscription); | 1215 onSubscriptionMessage("disabled", subscription); |
| 1190 } | 1216 } |
| 1191 else | 1217 else |
| 1192 { | 1218 { |
| 1193 delete subscriptionsMap[subscription.url]; | 1219 delete subscriptionsMap[subscription.url]; |
| 1194 if (isAcceptableAds(subscription.url)) | 1220 if (isAcceptableAds(subscription.url)) |
| 1195 { | 1221 { |
| 1196 setAcceptableAds(); | 1222 setAcceptableAds(); |
| 1197 } | 1223 } |
| 1198 else | 1224 else |
| 1199 { | 1225 { |
| 1200 collections.more.removeItem(subscription); | 1226 collections.more.removeItem(subscription); |
| 1201 } | 1227 } |
| 1202 } | 1228 } |
| 1203 collections.filterLists.removeItem(subscription); | 1229 collections.filterLists.removeItem(subscription); |
| 1204 break; | 1230 break; |
| 1205 } | 1231 } |
| 1206 | |
| 1207 } | 1232 } |
| 1208 | 1233 |
| 1209 function hidePref(key, value) | 1234 function hidePref(key, value) |
| 1210 { | 1235 { |
| 1211 let element = document.querySelector("[data-pref='" + key + "']"); | 1236 let element = document.querySelector("[data-pref='" + key + "']"); |
| 1212 if (element) | 1237 if (element) |
| 1213 element.setAttribute("aria-hidden", value); | 1238 element.setAttribute("aria-hidden", value); |
| 1214 } | 1239 } |
| 1215 | 1240 |
| 1216 function getPref(key, callback) | 1241 function getPref(key, callback) |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1322 type: "app.listen", | 1347 type: "app.listen", |
| 1323 filter: ["addSubscription", "focusSection"] | 1348 filter: ["addSubscription", "focusSection"] |
| 1324 }); | 1349 }); |
| 1325 ext.backgroundPage.sendMessage({ | 1350 ext.backgroundPage.sendMessage({ |
| 1326 type: "filters.listen", | 1351 type: "filters.listen", |
| 1327 filter: ["added", "loaded", "removed"] | 1352 filter: ["added", "loaded", "removed"] |
| 1328 }); | 1353 }); |
| 1329 ext.backgroundPage.sendMessage({ | 1354 ext.backgroundPage.sendMessage({ |
| 1330 type: "prefs.listen", | 1355 type: "prefs.listen", |
| 1331 filter: ["notifications_ignoredcategories", "notifications_showui", | 1356 filter: ["notifications_ignoredcategories", "notifications_showui", |
| 1332 "show_devtools_panel", "shouldShowBlockElementMenu"] | 1357 "show_devtools_panel", "shouldShowBlockElementMenu", |
| 1358 "ui_warn_tracking"] | |
|
Thomas Greiner
2017/09/22 10:05:43
Detail: We're no longer reacting to changes for th
| |
| 1333 }); | 1359 }); |
| 1334 ext.backgroundPage.sendMessage({ | 1360 ext.backgroundPage.sendMessage({ |
| 1335 type: "subscriptions.listen", | 1361 type: "subscriptions.listen", |
| 1336 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1362 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
| 1337 "title", "downloadStatus", "downloading"] | 1363 "title", "downloadStatus", "downloading"] |
| 1338 }); | 1364 }); |
| 1339 | 1365 |
| 1340 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1366 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
| 1341 window.addEventListener("hashchange", onHashChange, false); | 1367 window.addEventListener("hashchange", onHashChange, false); |
| 1342 } | 1368 } |
| OLD | NEW |