Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 return; | 119 return; |
120 } | 120 } |
121 | 121 |
122 setChecked("adblockplus-savestats", Prefs.savestats); | 122 setChecked("adblockplus-savestats", Prefs.savestats); |
123 addCommandHandler("adblockplus-savestats", function() | 123 addCommandHandler("adblockplus-savestats", function() |
124 { | 124 { |
125 UI.toggleSaveStats(doc.defaultView); | 125 UI.toggleSaveStats(doc.defaultView); |
126 this.value = Prefs.savestats; | 126 this.value = Prefs.savestats; |
127 }); | 127 }); |
128 | 128 |
129 let hasAcceptableAds = FilterStorage.subscriptions.some((subscription) => subscription instanceof DownloadableSubscription | 129 let hasAcceptableAds = FilterStorage.subscriptions.some((subscription) => subscription instanceof DownloadableSubscription && |
130 && subscription.url == Prefs.subscriptions_exceptionsurl); | 130 subscription.url == Prefs.subscriptions_exceptionsurl); |
Wladimir Palant
2014/05/15 07:12:38
It should be either operator on new line (like her
| |
131 setChecked("adblockplus-acceptableAds", hasAcceptableAds); | 131 setChecked("adblockplus-acceptableAds", hasAcceptableAds); |
132 addCommandHandler("adblockplus-acceptableAds", function() | 132 addCommandHandler("adblockplus-acceptableAds", function() |
133 { | 133 { |
134 this.value = UI.toggleAcceptableAds(); | 134 this.value = UI.toggleAcceptableAds(); |
135 }); | 135 }); |
136 | 136 |
137 setChecked("adblockplus-sync", syncEngine && syncEngine.enabled); | 137 setChecked("adblockplus-sync", syncEngine && syncEngine.enabled); |
138 addCommandHandler("adblockplus-sync", function() | 138 addCommandHandler("adblockplus-sync", function() |
139 { | 139 { |
140 this.value = UI.toggleSync(); | 140 this.value = UI.toggleSync(); |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
758 let addAcceptable = (Services.vc.compare(prevVersion, "2.0") < 0); | 758 let addAcceptable = (Services.vc.compare(prevVersion, "2.0") < 0); |
759 let privacySubscriptions = { | 759 let privacySubscriptions = { |
760 "https://easylist-downloads.adblockplus.org/easyprivacy+easylist.txt": tru e, | 760 "https://easylist-downloads.adblockplus.org/easyprivacy+easylist.txt": tru e, |
761 "https://easylist-downloads.adblockplus.org/easyprivacy.txt": true, | 761 "https://easylist-downloads.adblockplus.org/easyprivacy.txt": true, |
762 "https://secure.fanboy.co.nz/fanboy-tracking.txt": true, | 762 "https://secure.fanboy.co.nz/fanboy-tracking.txt": true, |
763 "https://fanboy-adblock-list.googlecode.com/hg/fanboy-adblocklist-stats.tx t": true, | 763 "https://fanboy-adblock-list.googlecode.com/hg/fanboy-adblocklist-stats.tx t": true, |
764 "https://bitbucket.org/fanboy/fanboyadblock/raw/tip/fanboy-adblocklist-sta ts.txt": true, | 764 "https://bitbucket.org/fanboy/fanboyadblock/raw/tip/fanboy-adblocklist-sta ts.txt": true, |
765 "https://hg01.codeplex.com/fanboyadblock/raw-file/tip/fanboy-adblocklist-s tats.txt": true, | 765 "https://hg01.codeplex.com/fanboyadblock/raw-file/tip/fanboy-adblocklist-s tats.txt": true, |
766 "https://adversity.googlecode.com/hg/Adversity-Tracking.txt": true | 766 "https://adversity.googlecode.com/hg/Adversity-Tracking.txt": true |
767 }; | 767 }; |
768 if (FilterStorage.subscriptions.some(subscription => subscription.url == Pre fs.subscriptions_exceptionsurl || subscription.url in privacySubscriptions)) | 768 if (FilterStorage.subscriptions.some((subscription) => subscription.url == P refs.subscriptions_exceptionsurl || subscription.url in privacySubscriptions)) |
Wladimir Palant
2014/05/15 07:12:38
According to https://developer.mozilla.org/en/docs
| |
769 addAcceptable = false; | 769 addAcceptable = false; |
770 | 770 |
771 // Don't add subscription if the user has a subscription already | 771 // Don't add subscription if the user has a subscription already |
772 let addSubscription = true; | 772 let addSubscription = true; |
773 if (FilterStorage.subscriptions.some(subscription => subscription instanceof DownloadableSubscription && subscription.url != Prefs.subscriptions_exceptionsu rl)) | 773 if (FilterStorage.subscriptions.some((subscription) => subscription instance of DownloadableSubscription && subscription.url != Prefs.subscriptions_exception surl)) |
774 addSubscription = false; | 774 addSubscription = false; |
775 | 775 |
776 // If this isn't the first run, only add subscription if the user has no cus tom filters | 776 // If this isn't the first run, only add subscription if the user has no cus tom filters |
777 if (addSubscription && Services.vc.compare(prevVersion, "0.0") > 0) | 777 if (addSubscription && Services.vc.compare(prevVersion, "0.0") > 0) |
778 { | 778 { |
779 if (FilterStorage.subscriptions.some(subscription => subscription.url != P refs.subscriptions_exceptionsurl && subscription.filters.length)) | 779 if (FilterStorage.subscriptions.some((subscription) => subscription.url != Prefs.subscriptions_exceptionsurl && subscription.filters.length)) |
780 addSubscription = false; | 780 addSubscription = false; |
781 } | 781 } |
782 | 782 |
783 // Add "acceptable ads" subscription | 783 // Add "acceptable ads" subscription |
784 if (addAcceptable) | 784 if (addAcceptable) |
785 { | 785 { |
786 let subscription = Subscription.fromURL(Prefs.subscriptions_exceptionsurl) ; | 786 let subscription = Subscription.fromURL(Prefs.subscriptions_exceptionsurl) ; |
787 if (subscription) | 787 if (subscription) |
788 { | 788 { |
789 subscription.title = "Allow non-intrusive advertising"; | 789 subscription.title = "Allow non-intrusive advertising"; |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1069 if (!icon) | 1069 if (!icon) |
1070 return; | 1070 return; |
1071 | 1071 |
1072 let state = (Prefs.enabled ? "active" : "disabled"); | 1072 let state = (Prefs.enabled ? "active" : "disabled"); |
1073 if (state == "active") | 1073 if (state == "active") |
1074 { | 1074 { |
1075 let location = this.getCurrentLocation(window); | 1075 let location = this.getCurrentLocation(window); |
1076 if (location && Policy.isWhitelisted(location.spec)) | 1076 if (location && Policy.isWhitelisted(location.spec)) |
1077 state = "whitelisted"; | 1077 state = "whitelisted"; |
1078 } | 1078 } |
1079 | 1079 |
1080 let popupId = "abp-status-popup"; | |
1080 if (icon.localName == "statusbarpanel") | 1081 if (icon.localName == "statusbarpanel") |
1081 { | 1082 { |
1082 if (Prefs.defaultstatusbaraction == 0) | 1083 if (Prefs.defaultstatusbaraction == 0) |
1083 icon.setAttribute("popup", icon.getAttribute("context")); | 1084 { |
1085 icon.setAttribute("popup", popupId); | |
1086 icon.removeAttribute("context"); | |
1087 } | |
1084 else | 1088 else |
1089 { | |
1085 icon.removeAttribute("popup"); | 1090 icon.removeAttribute("popup"); |
1091 icon.setAttribute("context", popupId); | |
1092 } | |
1086 } | 1093 } |
1087 else | 1094 else |
1088 { | 1095 { |
1089 if (Prefs.defaulttoolbaraction == 0) | 1096 if (Prefs.defaulttoolbaraction == 0) |
1097 { | |
1090 icon.setAttribute("type", "menu"); | 1098 icon.setAttribute("type", "menu"); |
1099 icon.removeAttribute("context"); | |
1100 } | |
1091 else | 1101 else |
1102 { | |
1092 icon.setAttribute("type", "menu-button"); | 1103 icon.setAttribute("type", "menu-button"); |
1104 icon.setAttribute("context", popupId); | |
1105 } | |
1093 } | 1106 } |
1094 | 1107 |
1095 icon.setAttribute("abpstate", state); | 1108 icon.setAttribute("abpstate", state); |
1096 }, | 1109 }, |
1097 | 1110 |
1098 /** | 1111 /** |
1099 * Shows or hides status bar icons in all windows, according to pref. | 1112 * Shows or hides status bar icons in all windows, according to pref. |
1100 */ | 1113 */ |
1101 updateStatusbarIcon: function(/**Window*/ window) | 1114 updateStatusbarIcon: function(/**Window*/ window) |
1102 { | 1115 { |
(...skipping 29 matching lines...) Expand all Loading... | |
1132 Prefs[pref] = !Prefs[pref]; | 1145 Prefs[pref] = !Prefs[pref]; |
1133 }, | 1146 }, |
1134 | 1147 |
1135 /** | 1148 /** |
1136 * If the given filter is already in user's list, removes it from the list. Ot herwise adds it. | 1149 * If the given filter is already in user's list, removes it from the list. Ot herwise adds it. |
1137 */ | 1150 */ |
1138 toggleFilter: function(/**Filter*/ filter) | 1151 toggleFilter: function(/**Filter*/ filter) |
1139 { | 1152 { |
1140 if (filter.subscriptions.length) | 1153 if (filter.subscriptions.length) |
1141 { | 1154 { |
1142 if (filter.disabled || filter.subscriptions.some(subscription => !(subscri ption instanceof SpecialSubscription))) | 1155 if (filter.disabled || filter.subscriptions.some((subscription) => !(subsc ription instanceof SpecialSubscription))) |
1143 filter.disabled = !filter.disabled; | 1156 filter.disabled = !filter.disabled; |
1144 else | 1157 else |
1145 FilterStorage.removeFilter(filter); | 1158 FilterStorage.removeFilter(filter); |
1146 } | 1159 } |
1147 else | 1160 else |
1148 FilterStorage.addFilter(filter); | 1161 FilterStorage.addFilter(filter); |
1149 }, | 1162 }, |
1150 | 1163 |
1151 | 1164 |
1152 /** | 1165 /** |
(...skipping 15 matching lines...) Expand all Loading... | |
1168 }, | 1181 }, |
1169 | 1182 |
1170 /** | 1183 /** |
1171 * Sets the current filter subscription in a single-subscription scenario, | 1184 * Sets the current filter subscription in a single-subscription scenario, |
1172 * all other subscriptions will be removed. | 1185 * all other subscriptions will be removed. |
1173 */ | 1186 */ |
1174 setSubscription: function(url, title) | 1187 setSubscription: function(url, title) |
1175 { | 1188 { |
1176 let subscription = Subscription.fromURL(url); | 1189 let subscription = Subscription.fromURL(url); |
1177 let currentSubscriptions = FilterStorage.subscriptions.filter( | 1190 let currentSubscriptions = FilterStorage.subscriptions.filter( |
1178 subscription => subscription instanceof DownloadableSubscription && subscr iption.url != Prefs.subscriptions_exceptionsurl | 1191 ((subscription) => subscription instanceof DownloadableSubscription && sub scription.url != Prefs.subscriptions_exceptionsurl |
1179 ); | 1192 ); |
1180 if (!subscription || currentSubscriptions.indexOf(subscription) >= 0) | 1193 if (!subscription || currentSubscriptions.indexOf(subscription) >= 0) |
1181 return; | 1194 return; |
1182 | 1195 |
1183 for (let i = 0; i < currentSubscriptions.length; i++) | 1196 for (let i = 0; i < currentSubscriptions.length; i++) |
1184 FilterStorage.removeSubscription(currentSubscriptions[i]); | 1197 FilterStorage.removeSubscription(currentSubscriptions[i]); |
1185 | 1198 |
1186 subscription.title = title; | 1199 subscription.title = title; |
1187 FilterStorage.addSubscription(subscription); | 1200 FilterStorage.addSubscription(subscription); |
1188 if (subscription instanceof DownloadableSubscription && !subscription.lastDo wnload) | 1201 if (subscription instanceof DownloadableSubscription && !subscription.lastDo wnload) |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1312 return true; | 1325 return true; |
1313 } | 1326 } |
1314 return false; | 1327 return false; |
1315 }, | 1328 }, |
1316 | 1329 |
1317 /** | 1330 /** |
1318 * Updates state of the icon tooltip. | 1331 * Updates state of the icon tooltip. |
1319 */ | 1332 */ |
1320 fillIconTooltip: function(/**Event*/ event, /**Window*/ window) | 1333 fillIconTooltip: function(/**Event*/ event, /**Window*/ window) |
1321 { | 1334 { |
1322 let E = id => window.document.getElementById(id); | 1335 let E = (id) => window.document.getElementById(id); |
1323 | 1336 |
1324 let node = window.document.tooltipNode; | 1337 let node = window.document.tooltipNode; |
1325 if (!node || !node.hasAttribute("tooltip")) | 1338 if (!node || !node.hasAttribute("tooltip")) |
1326 { | 1339 { |
1327 event.preventDefault(); | 1340 event.preventDefault(); |
1328 return; | 1341 return; |
1329 } | 1342 } |
1330 | 1343 |
1331 // Prevent tooltip from overlapping menu | 1344 // Prevent tooltip from overlapping menu |
1332 for (let id of ["abp-toolbar-popup", "abp-status-popup"]) | 1345 for (let id of ["abp-toolbar-popup", "abp-status-popup"]) |
(...skipping 17 matching lines...) Expand all Loading... | |
1350 actionDescr.setAttribute("value", Utils.getString("action" + action + "_to oltip")); | 1363 actionDescr.setAttribute("value", Utils.getString("action" + action + "_to oltip")); |
1351 | 1364 |
1352 let statusDescr = E("abp-tooltip-status"); | 1365 let statusDescr = E("abp-tooltip-status"); |
1353 let state = node.getAttribute("abpstate"); | 1366 let state = node.getAttribute("abpstate"); |
1354 let statusStr = Utils.getString(state + "_tooltip"); | 1367 let statusStr = Utils.getString(state + "_tooltip"); |
1355 if (state == "active") | 1368 if (state == "active") |
1356 { | 1369 { |
1357 let [activeSubscriptions, activeFilters] = FilterStorage.subscriptions.red uce(function([subscriptions, filters], current) | 1370 let [activeSubscriptions, activeFilters] = FilterStorage.subscriptions.red uce(function([subscriptions, filters], current) |
1358 { | 1371 { |
1359 if (current instanceof SpecialSubscription) | 1372 if (current instanceof SpecialSubscription) |
1360 return [subscriptions, filters + current.filters.filter(filter => !fil ter.disabled).length]; | 1373 return [subscriptions, filters + current.filters.filter((filter) => !f ilter.disabled).length]; |
1361 else if (!current.disabled && !(Prefs.subscriptions_exceptionscheckbox & & current.url == Prefs.subscriptions_exceptionsurl)) | 1374 else if (!current.disabled && !(Prefs.subscriptions_exceptionscheckbox & & current.url == Prefs.subscriptions_exceptionsurl)) |
1362 return [subscriptions + 1, filters]; | 1375 return [subscriptions + 1, filters]; |
1363 else | 1376 else |
1364 return [subscriptions, filters] | 1377 return [subscriptions, filters] |
1365 }, [0, 0]); | 1378 }, [0, 0]); |
1366 | 1379 |
1367 statusStr = statusStr.replace(/\?1\?/, activeSubscriptions).replace(/\?2\? /, activeFilters); | 1380 statusStr = statusStr.replace(/\?1\?/, activeSubscriptions).replace(/\?2\? /, activeFilters); |
1368 } | 1381 } |
1369 statusDescr.setAttribute("value", statusStr); | 1382 statusDescr.setAttribute("value", statusStr); |
1370 | 1383 |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1920 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], | 1933 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], |
1921 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] | 1934 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] |
1922 ]; | 1935 ]; |
1923 | 1936 |
1924 onShutdown.add(function() | 1937 onShutdown.add(function() |
1925 { | 1938 { |
1926 for (let window in UI.applicationWindows) | 1939 for (let window in UI.applicationWindows) |
1927 if (UI.isBottombarOpen(window)) | 1940 if (UI.isBottombarOpen(window)) |
1928 UI.toggleBottombar(window); | 1941 UI.toggleBottombar(window); |
1929 }); | 1942 }); |
LEFT | RIGHT |