| 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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 // Advanced tab | 700 // Advanced tab |
| 701 var tweaks = document.querySelectorAll("#tweaks li[data-pref]"); | 701 var tweaks = document.querySelectorAll("#tweaks li[data-pref]"); |
| 702 tweaks = Array.prototype.map.call(tweaks, function(checkbox) | 702 tweaks = Array.prototype.map.call(tweaks, function(checkbox) |
| 703 { | 703 { |
| 704 return checkbox.getAttribute("data-pref"); | 704 return checkbox.getAttribute("data-pref"); |
| 705 }); | 705 }); |
| 706 tweaks.forEach(function(key) | 706 tweaks.forEach(function(key) |
| 707 { | 707 { |
| 708 getPref(key, function(value) | 708 getPref(key, function(value) |
| 709 { | 709 { |
| 710 onPrefMessage(key, value); | 710 onPrefMessage(key, value, true); |
| 711 }); | 711 }); |
| 712 }); | 712 }); |
| 713 ext.backgroundPage.sendMessage( | 713 ext.backgroundPage.sendMessage( |
| 714 { | 714 { |
| 715 type: "app.get", | 715 type: "app.get", |
| 716 what: "features" | 716 what: "features" |
| 717 }, | 717 }, |
| 718 function(features) | 718 function(features) |
| 719 { | 719 { |
| 720 hidePref("show_devtools_panel", !features.devToolsPanel); | 720 hidePref("show_devtools_panel", !features.devToolsPanel); |
| 721 hidePref("safari_contentblocker", !features.safariContentBlocker); | 721 |
| 722 // Only show option to switch between Safari Content Blockers |
| 723 // and event based blocking if both are available. |
| 724 hidePref("safari_contentblocker", !( |
| 725 features.safariContentBlocker && |
| 726 "canLoad" in safari.self.tab && |
| 727 "onbeforeload" in Element.prototype |
| 728 )); |
| 722 }); | 729 }); |
| 723 | 730 |
| 724 var filterTextbox = document.querySelector("#custom-filters-add input"); | 731 var filterTextbox = document.querySelector("#custom-filters-add input"); |
| 725 placeholderValue = getMessage("options_customFilters_textbox_placeholder"); | 732 placeholderValue = getMessage("options_customFilters_textbox_placeholder"); |
| 726 filterTextbox.setAttribute("placeholder", placeholderValue); | 733 filterTextbox.setAttribute("placeholder", placeholderValue); |
| 727 function addCustomFilters() | 734 function addCustomFilters() |
| 728 { | 735 { |
| 729 var filterText = filterTextbox.value; | 736 var filterText = filterTextbox.value; |
| 730 sendMessageHandleErrors( | 737 sendMessageHandleErrors( |
| 731 { | 738 { |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 }; | 1021 }; |
| 1015 | 1022 |
| 1016 getPref.checks = | 1023 getPref.checks = |
| 1017 { | 1024 { |
| 1018 notifications_ignoredcategories: function(callback) | 1025 notifications_ignoredcategories: function(callback) |
| 1019 { | 1026 { |
| 1020 getPref("notifications_showui", callback); | 1027 getPref("notifications_showui", callback); |
| 1021 } | 1028 } |
| 1022 }; | 1029 }; |
| 1023 | 1030 |
| 1024 function onPrefMessage(key, value) | 1031 function onPrefMessage(key, value, initial) |
| 1025 { | 1032 { |
| 1033 switch (key) |
| 1034 { |
| 1035 case "notifications_ignoredcategories": |
| 1036 value = value.indexOf("*") == -1; |
| 1037 break; |
| 1038 |
| 1039 case "notifications_showui": |
| 1040 hidePref("notifications_ignoredcategories", !value); |
| 1041 break; |
| 1042 |
| 1043 case "safari_contentblocker": |
| 1044 E("restart-safari").setAttribute("aria-hidden", value || initial); |
| 1045 break; |
| 1046 } |
| 1047 |
| 1026 var checkbox = document.querySelector("[data-pref='" + key + "'] button[role
='checkbox']"); | 1048 var checkbox = document.querySelector("[data-pref='" + key + "'] button[role
='checkbox']"); |
| 1027 if (checkbox) | 1049 if (checkbox) |
| 1028 { | |
| 1029 if (key == "notifications_ignoredcategories") | |
| 1030 value = (value.indexOf("*") == -1); | |
| 1031 checkbox.setAttribute("aria-checked", value); | 1050 checkbox.setAttribute("aria-checked", value); |
| 1032 } | |
| 1033 else if (key == "notifications_showui") | |
| 1034 hidePref("notifications_ignoredcategories", !value); | |
| 1035 } | 1051 } |
| 1036 | 1052 |
| 1037 function onShareLinkClick(e) | 1053 function onShareLinkClick(e) |
| 1038 { | 1054 { |
| 1039 e.preventDefault(); | 1055 e.preventDefault(); |
| 1040 | 1056 |
| 1041 getDocLink("share-general", function(link) | 1057 getDocLink("share-general", function(link) |
| 1042 { | 1058 { |
| 1043 openSharePopup(link); | 1059 openSharePopup(link); |
| 1044 }); | 1060 }); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 var dialog = E("dialog-content-predefined"); | 1102 var dialog = E("dialog-content-predefined"); |
| 1087 dialog.querySelector("h3").textContent = subscription.title || ""; | 1103 dialog.querySelector("h3").textContent = subscription.title || ""; |
| 1088 dialog.querySelector(".url").textContent = subscription.url; | 1104 dialog.querySelector(".url").textContent = subscription.url; |
| 1089 openDialog("predefined"); | 1105 openDialog("predefined"); |
| 1090 } | 1106 } |
| 1091 break; | 1107 break; |
| 1092 case "filters.respond": | 1108 case "filters.respond": |
| 1093 onFilterMessage(message.action, message.args[0]); | 1109 onFilterMessage(message.action, message.args[0]); |
| 1094 break; | 1110 break; |
| 1095 case "prefs.respond": | 1111 case "prefs.respond": |
| 1096 onPrefMessage(message.action, message.args[0]); | 1112 onPrefMessage(message.action, message.args[0], false); |
| 1097 break; | 1113 break; |
| 1098 case "subscriptions.respond": | 1114 case "subscriptions.respond": |
| 1099 onSubscriptionMessage(message.action, message.args[0]); | 1115 onSubscriptionMessage(message.action, message.args[0]); |
| 1100 break; | 1116 break; |
| 1101 } | 1117 } |
| 1102 }); | 1118 }); |
| 1103 | 1119 |
| 1104 ext.backgroundPage.sendMessage( | 1120 ext.backgroundPage.sendMessage( |
| 1105 { | 1121 { |
| 1106 type: "app.listen", | 1122 type: "app.listen", |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1120 }); | 1136 }); |
| 1121 ext.backgroundPage.sendMessage( | 1137 ext.backgroundPage.sendMessage( |
| 1122 { | 1138 { |
| 1123 type: "subscriptions.listen", | 1139 type: "subscriptions.listen", |
| 1124 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1140 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
| 1125 "title"] | 1141 "title"] |
| 1126 }); | 1142 }); |
| 1127 | 1143 |
| 1128 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1144 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
| 1129 })(); | 1145 })(); |
| OLD | NEW |