| Left: | ||
| Right: |
| 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 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; | |
| 33 let filterErrors = new Map([ | 32 let filterErrors = new Map([ |
| 34 ["synchronize_invalid_url", | 33 ["synchronize_invalid_url", |
| 35 "options_filterList_lastDownload_invalidURL"], | 34 "options_filterList_lastDownload_invalidURL"], |
| 36 ["synchronize_connection_error", | 35 ["synchronize_connection_error", |
| 37 "options_filterList_lastDownload_connectionError"], | 36 "options_filterList_lastDownload_connectionError"], |
| 38 ["synchronize_invalid_data", | 37 ["synchronize_invalid_data", |
| 39 "options_filterList_lastDownload_invalidData"], | 38 "options_filterList_lastDownload_invalidData"], |
| 40 ["synchronize_checksum_mismatch", | 39 ["synchronize_checksum_mismatch", |
| 41 "options_filterList_lastDownload_checksumMismatch"] | 40 "options_filterList_lastDownload_checksumMismatch"] |
| 42 ]); | 41 ]); |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 id: "blocking-languages-table", | 345 id: "blocking-languages-table", |
| 347 emptyText: ["options_language_empty"] | 346 emptyText: ["options_language_empty"] |
| 348 } | 347 } |
| 349 ]); | 348 ]); |
| 350 collections.allLangs = new Collection([ | 349 collections.allLangs = new Collection([ |
| 351 { | 350 { |
| 352 id: "all-lang-table-add", | 351 id: "all-lang-table-add", |
| 353 emptyText: ["options_dialog_language_other_empty"] | 352 emptyText: ["options_dialog_language_other_empty"] |
| 354 } | 353 } |
| 355 ]); | 354 ]); |
| 356 collections.custom = new Collection([ | 355 collections.more = new Collection([ |
| 357 { | 356 { |
| 358 id: "custom-list-table" | 357 id: "more-list-table" |
| 359 } | 358 } |
| 360 ]); | 359 ]); |
| 361 collections.whitelist = new Collection([ | 360 collections.whitelist = new Collection([ |
| 362 { | 361 { |
| 363 id: "whitelisting-table", | 362 id: "whitelisting-table", |
| 364 emptyText: ["options_whitelist_empty_1", "options_whitelist_empty_2"] | 363 emptyText: ["options_whitelist_empty_1", "options_whitelist_empty_2"] |
| 365 } | 364 } |
| 366 ]); | 365 ]); |
| 367 collections.filterLists = new Collection([ | 366 collections.filterLists = new Collection([ |
| 368 { | 367 { |
| 369 id: "all-filter-lists-table", | 368 id: "all-filter-lists-table", |
| 370 useOriginalTitle: true | 369 useOriginalTitle: true |
| 371 } | 370 } |
| 372 ]); | 371 ]); |
| 373 | 372 |
| 374 function addSubscription(subscription) | 373 function addSubscription(subscription) |
| 375 { | 374 { |
| 375 let {disabled} = subscription; | |
| 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 (subscription.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 } |
| 386 else | 386 else |
| 387 { | 387 { |
| 388 collection = collections.protection; | 388 collection = collections.protection; |
| 389 } | 389 } |
| 390 } | 390 } |
| 391 else if (!isAcceptableAds(subscription.url)) | 391 else if (!isAcceptableAds(subscription.url) && disabled == false) |
| 392 { | 392 { |
| 393 collection = collections.custom; | 393 collection = collections.more; |
| 394 } | 394 } |
| 395 | 395 |
| 396 if (collection) | 396 if (collection) |
| 397 collection.addItem(subscription); | 397 collection.addItem(subscription); |
| 398 | 398 |
| 399 subscriptionsMap[subscription.url] = subscription; | 399 subscriptionsMap[subscription.url] = subscription; |
| 400 updateTooltips(); | 400 updateTooltips(); |
| 401 } | 401 } |
| 402 | 402 |
| 403 function updateSubscription(subscription) | 403 function updateSubscription(subscription) |
| 404 { | 404 { |
| 405 for (let name in collections) | 405 for (let name in collections) |
| 406 collections[name].updateItem(subscription); | 406 collections[name].updateItem(subscription); |
| 407 | 407 |
| 408 if (subscription.recommended == "ads") | 408 if (subscription.recommended == "ads") |
| 409 { | 409 { |
| 410 if (subscription.disabled) | 410 if (subscription.disabled) |
| 411 collections.langs.removeItem(subscription); | 411 collections.langs.removeItem(subscription); |
| 412 else | 412 else |
| 413 collections.langs.addItem(subscription); | 413 collections.langs.addItem(subscription); |
| 414 } | 414 } |
| 415 else if (!subscription.recommended && !isAcceptableAds(subscription.url)) | 415 else if (!subscription.recommended && !isAcceptableAds(subscription.url)) |
| 416 { | 416 { |
| 417 if (subscription.disabled == false) | 417 if (subscription.disabled == false) |
| 418 { | 418 { |
| 419 collections.custom.addItem(subscription); | 419 collections.more.addItem(subscription); |
| 420 updateTooltips(); | 420 updateTooltips(); |
| 421 } | 421 } |
| 422 else | 422 else |
| 423 { | 423 { |
| 424 collections.custom.removeItem(subscription); | 424 collections.more.removeItem(subscription); |
| 425 } | 425 } |
| 426 } | 426 } |
| 427 } | 427 } |
| 428 | 428 |
| 429 function updateFilter(filter) | 429 function updateFilter(filter) |
| 430 { | 430 { |
| 431 let match = filter.text.match(whitelistedDomainRegexp); | 431 let match = filter.text.match(whitelistedDomainRegexp); |
| 432 if (match && !filtersMap[filter.text]) | 432 if (match && !filtersMap[filter.text]) |
| 433 { | 433 { |
| 434 filter.title = match[1]; | 434 filter.title = match[1]; |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 670 ext.backgroundPage.sendMessage({ | 670 ext.backgroundPage.sendMessage({ |
| 671 type: "subscriptions.update" | 671 type: "subscriptions.update" |
| 672 }); | 672 }); |
| 673 break; | 673 break; |
| 674 case "update-subscription": | 674 case "update-subscription": |
| 675 ext.backgroundPage.sendMessage({ | 675 ext.backgroundPage.sendMessage({ |
| 676 type: "subscriptions.update", | 676 type: "subscriptions.update", |
| 677 url: findParentData(element, "access", false) | 677 url: findParentData(element, "access", false) |
| 678 }); | 678 }); |
| 679 break; | 679 break; |
| 680 case "validate-import-subscription": | |
| 681 let form = findParentData(element, "validation", true); | |
| 682 if (!form) | |
| 683 return; | |
| 684 | |
| 685 if (form.checkValidity()) | |
| 686 { | |
| 687 addEnableSubscription(E("import-list-url").value, | |
| 688 E("import-list-title").value); | |
| 689 form.reset(); | |
| 690 closeDialog(); | |
| 691 } | |
| 692 else | |
| 693 { | |
| 694 form.querySelector(":invalid").focus(); | |
| 695 } | |
| 696 break; | |
| 680 } | 697 } |
| 681 } | 698 } |
| 682 | 699 |
| 683 function setCustomFiltersView(mode) | 700 function setCustomFiltersView(mode) |
| 684 { | 701 { |
| 685 let customFiltersElement = E("custom-filters-raw"); | 702 let customFiltersElement = E("custom-filters-raw"); |
| 686 updateCustomFiltersUi(); | 703 updateCustomFiltersUi(); |
| 687 if (mode == "read") | 704 if (mode == "read") |
| 688 { | 705 { |
| 689 customFiltersElement.disabled = true; | 706 customFiltersElement.disabled = true; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 833 document.body.addEventListener("click", onClick, false); | 850 document.body.addEventListener("click", onClick, false); |
| 834 document.body.addEventListener("keyup", onKeyUp, false); | 851 document.body.addEventListener("keyup", onKeyUp, false); |
| 835 let exampleValue = getMessage("options_whitelist_placeholder_example", | 852 let exampleValue = getMessage("options_whitelist_placeholder_example", |
| 836 ["www.example.com"]); | 853 ["www.example.com"]); |
| 837 E("whitelisting-textbox").setAttribute("placeholder", exampleValue); | 854 E("whitelisting-textbox").setAttribute("placeholder", exampleValue); |
| 838 E("whitelisting-textbox").addEventListener("keyup", (e) => | 855 E("whitelisting-textbox").addEventListener("keyup", (e) => |
| 839 { | 856 { |
| 840 E("whitelisting-add-button").disabled = !e.target.value; | 857 E("whitelisting-add-button").disabled = !e.target.value; |
| 841 }, false); | 858 }, false); |
| 842 | 859 |
| 843 getPref("ui_warn_tracking", (value) => | |
| 844 { | |
| 845 showTrackingWarning = value; | |
| 846 }); | |
| 847 getDocLink("contribute", (link) => | 860 getDocLink("contribute", (link) => |
| 848 { | 861 { |
| 849 E("contribute").href = link; | 862 E("contribute").href = link; |
| 850 }); | 863 }); |
| 851 getDocLink("acceptable_ads_criteria", (link) => | 864 getDocLink("acceptable_ads_criteria", (link) => |
| 852 { | 865 { |
| 853 setLinks("enable-aa-description", link); | 866 setLinks("enable-aa-description", link); |
| 854 }); | 867 }); |
| 855 | 868 |
| 856 // Advanced tab | 869 // Advanced tab |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1185 updateSubscription(subscription); | 1198 updateSubscription(subscription); |
| 1186 break; | 1199 break; |
| 1187 case "downloading": | 1200 case "downloading": |
| 1188 case "downloadStatus": | 1201 case "downloadStatus": |
| 1189 case "homepage": | 1202 case "homepage": |
| 1190 case "lastDownload": | 1203 case "lastDownload": |
| 1191 case "title": | 1204 case "title": |
| 1192 updateSubscription(subscription); | 1205 updateSubscription(subscription); |
| 1193 break; | 1206 break; |
| 1194 case "added": | 1207 case "added": |
| 1195 let url = subscription.url; | 1208 let {url, recommended} = subscription; |
| 1196 if (url in subscriptionsMap) | 1209 if (url in subscriptionsMap) |
| 1197 updateSubscription(subscription); | 1210 updateSubscription(subscription); |
| 1198 else | 1211 else |
| 1199 addSubscription(subscription); | 1212 addSubscription(subscription); |
| 1200 | 1213 |
| 1201 if (isAcceptableAds(url)) | 1214 if (isAcceptableAds(url)) |
| 1202 setAcceptableAds(); | 1215 setAcceptableAds(); |
| 1203 | 1216 |
| 1204 if (url == acceptableAdsUrl || subscription.recommended == "privacy") | 1217 if ((url == acceptableAdsUrl || recommended == "privacy") && |
| 1205 { | 1218 hasPrivacyConflict()) |
| 1206 if (hasPrivacyConflict() && showTrackingWarning) | 1219 { |
|
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"); | 1220 getPref("ui_warn_tracking", (showTrackingWarning) => |
| 1221 { | |
| 1222 if (showTrackingWarning) | |
| 1223 openDialog("tracking"); | |
| 1224 }); | |
| 1208 } | 1225 } |
| 1209 | 1226 |
| 1210 collections.filterLists.addItem(subscription); | 1227 collections.filterLists.addItem(subscription); |
| 1211 break; | 1228 break; |
| 1212 case "removed": | 1229 case "removed": |
| 1213 if (subscription.recommended) | 1230 if (subscription.recommended) |
| 1214 { | 1231 { |
| 1215 subscription.disabled = true; | 1232 subscription.disabled = true; |
| 1216 onSubscriptionMessage("disabled", subscription); | 1233 onSubscriptionMessage("disabled", subscription); |
| 1217 } | 1234 } |
| 1218 else | 1235 else |
| 1219 { | 1236 { |
| 1220 delete subscriptionsMap[subscription.url]; | 1237 delete subscriptionsMap[subscription.url]; |
| 1221 if (isAcceptableAds(subscription.url)) | 1238 if (isAcceptableAds(subscription.url)) |
| 1222 { | 1239 { |
| 1223 setAcceptableAds(); | 1240 setAcceptableAds(); |
| 1224 } | 1241 } |
| 1225 else | 1242 else |
| 1226 { | 1243 { |
| 1227 collections.custom.removeItem(subscription); | 1244 collections.more.removeItem(subscription); |
| 1228 } | 1245 } |
| 1229 } | 1246 } |
| 1230 collections.filterLists.removeItem(subscription); | 1247 collections.filterLists.removeItem(subscription); |
| 1231 break; | 1248 break; |
| 1232 } | 1249 } |
| 1233 | |
| 1234 } | 1250 } |
| 1235 | 1251 |
| 1236 function hidePref(key, value) | 1252 function hidePref(key, value) |
| 1237 { | 1253 { |
| 1238 let element = document.querySelector("[data-pref='" + key + "']"); | 1254 let element = document.querySelector("[data-pref='" + key + "']"); |
| 1239 if (element) | 1255 if (element) |
| 1240 element.setAttribute("aria-hidden", value); | 1256 element.setAttribute("aria-hidden", value); |
| 1241 } | 1257 } |
| 1242 | 1258 |
| 1243 function getPref(key, callback) | 1259 function getPref(key, callback) |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 1274 function onPrefMessage(key, value, initial) | 1290 function onPrefMessage(key, value, initial) |
| 1275 { | 1291 { |
| 1276 switch (key) | 1292 switch (key) |
| 1277 { | 1293 { |
| 1278 case "notifications_ignoredcategories": | 1294 case "notifications_ignoredcategories": |
| 1279 value = value.indexOf("*") == -1; | 1295 value = value.indexOf("*") == -1; |
| 1280 break; | 1296 break; |
| 1281 | 1297 |
| 1282 case "notifications_showui": | 1298 case "notifications_showui": |
| 1283 hidePref("notifications_ignoredcategories", !value); | 1299 hidePref("notifications_ignoredcategories", !value); |
| 1284 break; | |
| 1285 | |
| 1286 case "ui_warn_tracking": | |
| 1287 showTrackingWarning = value; | |
| 1288 break; | 1300 break; |
| 1289 } | 1301 } |
| 1290 | 1302 |
| 1291 let checkbox = document.querySelector( | 1303 let checkbox = document.querySelector( |
| 1292 "[data-pref='" + key + "'] button[role='checkbox']" | 1304 "[data-pref='" + key + "'] button[role='checkbox']" |
| 1293 ); | 1305 ); |
| 1294 if (checkbox) | 1306 if (checkbox) |
| 1295 checkbox.setAttribute("aria-checked", value); | 1307 checkbox.setAttribute("aria-checked", value); |
| 1296 } | 1308 } |
| 1297 | 1309 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1365 }); | 1377 }); |
| 1366 ext.backgroundPage.sendMessage({ | 1378 ext.backgroundPage.sendMessage({ |
| 1367 type: "subscriptions.listen", | 1379 type: "subscriptions.listen", |
| 1368 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1380 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
| 1369 "title", "downloadStatus", "downloading"] | 1381 "title", "downloadStatus", "downloading"] |
| 1370 }); | 1382 }); |
| 1371 | 1383 |
| 1372 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1384 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
| 1373 window.addEventListener("hashchange", onHashChange, false); | 1385 window.addEventListener("hashchange", onHashChange, false); |
| 1374 } | 1386 } |
| LEFT | RIGHT |