| 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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 }); | 552 }); |
| 553 } | 553 } |
| 554 | 554 |
| 555 function switchTab(id) | 555 function switchTab(id) |
| 556 { | 556 { |
| 557 location.hash = id; | 557 location.hash = id; |
| 558 } | 558 } |
| 559 | 559 |
| 560 function execAction(action, element) | 560 function execAction(action, element) |
| 561 { | 561 { |
| 562 if (element.getAttribute("aria-disabled") == "true") |
| 563 return; |
| 564 |
| 562 switch (action) | 565 switch (action) |
| 563 { | 566 { |
| 564 case "add-domain-exception": | 567 case "add-domain-exception": |
| 565 addWhitelistedDomain(); | 568 addWhitelistedDomain(); |
| 566 break; | 569 break; |
| 567 case "add-language-subscription": | 570 case "add-language-subscription": |
| 568 addEnableSubscription(findParentData(element, "access", false)); | 571 addEnableSubscription(findParentData(element, "access", false)); |
| 569 break; | 572 break; |
| 570 case "add-predefined-subscription": { | 573 case "add-predefined-subscription": { |
| 571 let dialog = E("dialog-content-predefined"); | 574 let dialog = E("dialog-content-predefined"); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 () => | 650 () => |
| 648 { | 651 { |
| 649 setCustomFiltersView("read"); | 652 setCustomFiltersView("read"); |
| 650 }); | 653 }); |
| 651 break; | 654 break; |
| 652 case "show-more-filters-section": | 655 case "show-more-filters-section": |
| 653 E("more-filters").setAttribute("aria-hidden", false); | 656 E("more-filters").setAttribute("aria-hidden", false); |
| 654 break; | 657 break; |
| 655 case "switch-acceptable-ads": | 658 case "switch-acceptable-ads": |
| 656 let value = element.value || element.dataset.value; | 659 let value = element.value || element.dataset.value; |
| 657 browser.runtime.sendMessage({ | 660 // User check the checkbox |
| 658 type: value == "privacy" ? "subscriptions.add" : | 661 let isCheck = element.getAttribute("aria-checked") != "true"; |
| 659 "subscriptions.remove", | 662 |
| 660 url: acceptableAdsPrivacyUrl | 663 // Acceptable Ads checkbox clicked |
| 661 }); | 664 if (value == "ads") |
| 662 browser.runtime.sendMessage({ | 665 { |
| 663 type: value == "ads" ? "subscriptions.add" : "subscriptions.remove", | 666 browser.runtime.sendMessage({ |
| 664 url: acceptableAdsUrl | 667 type: isCheck ? "subscriptions.add" : |
| 665 }); | 668 "subscriptions.remove", |
| 669 url: acceptableAdsUrl |
| 670 }); |
| 671 browser.runtime.sendMessage({ |
| 672 type: "subscriptions.remove", |
| 673 url: acceptableAdsPrivacyUrl |
| 674 }); |
| 675 } |
| 676 else // Privacy Friendly Acceptable Ads checkbox clicked |
| 677 { |
| 678 browser.runtime.sendMessage({ |
| 679 type: isCheck ? "subscriptions.add" : |
| 680 "subscriptions.remove", |
| 681 url: acceptableAdsPrivacyUrl |
| 682 }); |
| 683 browser.runtime.sendMessage({ |
| 684 type: isCheck ? "subscriptions.remove" : |
| 685 "subscriptions.add", |
| 686 url: acceptableAdsUrl |
| 687 }); |
| 688 } |
| 666 break; | 689 break; |
| 667 case "switch-tab": | 690 case "switch-tab": |
| 668 switchTab(element.getAttribute("href").substr(1)); | 691 switchTab(element.getAttribute("href").substr(1)); |
| 669 break; | 692 break; |
| 670 case "toggle-disable-subscription": | 693 case "toggle-disable-subscription": |
| 671 browser.runtime.sendMessage({ | 694 browser.runtime.sendMessage({ |
| 672 type: "subscriptions.toggle", | 695 type: "subscriptions.toggle", |
| 673 keepInstalled: true, | 696 keepInstalled: true, |
| 674 url: findParentData(element, "access", false) | 697 url: findParentData(element, "access", false) |
| 675 }); | 698 }); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 { | 905 { |
| 883 E("whitelisting-add-button").disabled = !e.target.value; | 906 E("whitelisting-add-button").disabled = !e.target.value; |
| 884 }, false); | 907 }, false); |
| 885 | 908 |
| 886 getDocLink("contribute", (link) => | 909 getDocLink("contribute", (link) => |
| 887 { | 910 { |
| 888 E("contribute").href = link; | 911 E("contribute").href = link; |
| 889 }); | 912 }); |
| 890 getDocLink("acceptable_ads_criteria", (link) => | 913 getDocLink("acceptable_ads_criteria", (link) => |
| 891 { | 914 { |
| 892 setLinks("enable-aa-description", link); | 915 setLinks("enable-acceptable-ads-description", link); |
| 916 }); |
| 917 getDocLink("privacy_friendly_ads", (link) => |
| 918 { |
| 919 E("enable-acceptable-ads-privacy-description").href = link; |
| 893 }); | 920 }); |
| 894 getDocLink("adblock_plus_{browser}_dnt", url => | 921 getDocLink("adblock_plus_{browser}_dnt", url => |
| 895 { | 922 { |
| 896 setLinks("dnt", url); | 923 setLinks("dnt", url); |
| 897 }); | 924 }); |
| 898 | 925 |
| 899 // Advanced tab | 926 // Advanced tab |
| 900 let customize = document.querySelectorAll("#customize li[data-pref]"); | 927 let customize = document.querySelectorAll("#customize li[data-pref]"); |
| 901 customize = Array.prototype.map.call(customize, (checkbox) => | 928 customize = Array.prototype.map.call(customize, (checkbox) => |
| 902 { | 929 { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 } | 1054 } |
| 1028 | 1055 |
| 1029 function hideNotification() | 1056 function hideNotification() |
| 1030 { | 1057 { |
| 1031 E("notification").setAttribute("aria-hidden", true); | 1058 E("notification").setAttribute("aria-hidden", true); |
| 1032 E("notification-text").textContent = ""; | 1059 E("notification-text").textContent = ""; |
| 1033 } | 1060 } |
| 1034 | 1061 |
| 1035 function setAcceptableAds() | 1062 function setAcceptableAds() |
| 1036 { | 1063 { |
| 1037 let option = "none"; | 1064 let acceptableAdsForm = E("acceptable-ads"); |
| 1038 document.forms["acceptable-ads"].classList.remove("show-dnt-notification"); | 1065 let acceptableAds = E("acceptable-ads-allow"); |
| 1066 let acceptableAdsPrivacy = E("acceptable-ads-privacy-allow"); |
| 1067 acceptableAdsForm.classList.remove("show-dnt-notification"); |
| 1068 acceptableAds.setAttribute("aria-checked", false); |
| 1069 acceptableAdsPrivacy.setAttribute("aria-checked", false); |
| 1070 acceptableAdsPrivacy.setAttribute("tabindex", 0); |
| 1039 if (acceptableAdsUrl in subscriptionsMap) | 1071 if (acceptableAdsUrl in subscriptionsMap) |
| 1040 { | 1072 { |
| 1041 option = "ads"; | 1073 acceptableAds.setAttribute("aria-checked", true); |
| 1074 acceptableAdsPrivacy.setAttribute("aria-disabled", false); |
| 1042 } | 1075 } |
| 1043 else if (acceptableAdsPrivacyUrl in subscriptionsMap) | 1076 else if (acceptableAdsPrivacyUrl in subscriptionsMap) |
| 1044 { | 1077 { |
| 1045 option = "privacy"; | 1078 acceptableAds.setAttribute("aria-checked", true); |
| 1079 acceptableAdsPrivacy.setAttribute("aria-checked", true); |
| 1080 acceptableAdsPrivacy.setAttribute("aria-disabled", false); |
| 1046 | 1081 |
| 1047 if (!navigator.doNotTrack) | 1082 if (navigator.doNotTrack != 1) |
| 1048 document.forms["acceptable-ads"].classList.add("show-dnt-notification"); | 1083 acceptableAdsForm.classList.add("show-dnt-notification"); |
| 1049 } | 1084 } |
| 1050 document.forms["acceptable-ads"]["acceptable-ads"].value = option; | 1085 else |
| 1086 { |
| 1087 // Using aria-disabled in order to keep the focus |
| 1088 acceptableAdsPrivacy.setAttribute("aria-disabled", true); |
| 1089 acceptableAdsPrivacy.setAttribute("tabindex", -1); |
| 1090 } |
| 1051 } | 1091 } |
| 1052 | 1092 |
| 1053 function isAcceptableAds(url) | 1093 function isAcceptableAds(url) |
| 1054 { | 1094 { |
| 1055 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; | 1095 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; |
| 1056 } | 1096 } |
| 1057 | 1097 |
| 1058 function populateLists() | 1098 function populateLists() |
| 1059 { | 1099 { |
| 1060 subscriptionsMap = Object.create(null); | 1100 subscriptionsMap = Object.create(null); |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1380 }); | 1420 }); |
| 1381 browser.runtime.sendMessage({ | 1421 browser.runtime.sendMessage({ |
| 1382 type: "subscriptions.listen", | 1422 type: "subscriptions.listen", |
| 1383 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1423 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
| 1384 "title", "downloadStatus", "downloading"] | 1424 "title", "downloadStatus", "downloading"] |
| 1385 }); | 1425 }); |
| 1386 | 1426 |
| 1387 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1427 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
| 1388 window.addEventListener("hashchange", onHashChange, false); | 1428 window.addEventListener("hashchange", onHashChange, false); |
| 1389 } | 1429 } |
| OLD | NEW |