| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 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(function(subscript ion) subscription instanceof DownloadableSubscription && subscription.url == Pre fs.subscriptions_exceptionsurl); | 129 let hasAcceptableAds = FilterStorage.subscriptions.some((subscription) => subscription instanceof DownloadableSubscription |
| 130 && subscription.url == Prefs.subscriptions_exceptionsurl); | |
|
Wladimir Palant
2014/05/15 07:12:38
It should be either operator on new line (like her
| |
| 130 setChecked("adblockplus-acceptableAds", hasAcceptableAds); | 131 setChecked("adblockplus-acceptableAds", hasAcceptableAds); |
| 131 addCommandHandler("adblockplus-acceptableAds", function() | 132 addCommandHandler("adblockplus-acceptableAds", function() |
| 132 { | 133 { |
| 133 this.value = UI.toggleAcceptableAds(); | 134 this.value = UI.toggleAcceptableAds(); |
| 134 }); | 135 }); |
| 135 | 136 |
| 136 setChecked("adblockplus-sync", syncEngine && syncEngine.enabled); | 137 setChecked("adblockplus-sync", syncEngine && syncEngine.enabled); |
| 137 addCommandHandler("adblockplus-sync", function() | 138 addCommandHandler("adblockplus-sync", function() |
| 138 { | 139 { |
| 139 this.value = UI.toggleSync(); | 140 this.value = UI.toggleSync(); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 151 { | 152 { |
| 152 // Load subscriptions data | 153 // Load subscriptions data |
| 153 let request = new XMLHttpRequest(); | 154 let request = new XMLHttpRequest(); |
| 154 request.mozBackgroundRequest = true; | 155 request.mozBackgroundRequest = true; |
| 155 request.open("GET", "chrome://adblockplus/content/ui/subscriptions.xml") ; | 156 request.open("GET", "chrome://adblockplus/content/ui/subscriptions.xml") ; |
| 156 request.addEventListener("load", function() | 157 request.addEventListener("load", function() |
| 157 { | 158 { |
| 158 if (onShutdown.done) | 159 if (onShutdown.done) |
| 159 return; | 160 return; |
| 160 | 161 |
| 161 let currentSubscription = FilterStorage.subscriptions.filter( | 162 let currentSubscription = FilterStorage.subscriptions.filter((subscrip tion) => subscription instanceof DownloadableSubscription && |
| 162 function(subscription) subscription instanceof DownloadableSubscript ion && subscription.url != Prefs.subscriptions_exceptionsurl | 163 subscription.url != Prefs.subscriptions_exceptionsurl); |
| 163 ); | |
| 164 currentSubscription = (currentSubscription.length ? currentSubscriptio n[0] : null); | 164 currentSubscription = (currentSubscription.length ? currentSubscriptio n[0] : null); |
| 165 | 165 |
| 166 let subscriptions =request.responseXML.getElementsByTagName("subscript ion"); | 166 let subscriptions =request.responseXML.getElementsByTagName("subscript ion"); |
| 167 for (let i = 0; i < subscriptions.length; i++) | 167 for (let i = 0; i < subscriptions.length; i++) |
| 168 { | 168 { |
| 169 let item = subscriptions[i]; | 169 let item = subscriptions[i]; |
| 170 let url = item.getAttribute("url"); | 170 let url = item.getAttribute("url"); |
| 171 if (!url) | 171 if (!url) |
| 172 continue; | 172 continue; |
| 173 | 173 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 { | 332 { |
| 333 Utils.splitAllLabels(root); | 333 Utils.splitAllLabels(root); |
| 334 | 334 |
| 335 let specialElements = {"abp-status-popup": true, "abp-status": true, "abp-to olbarbutton": true, "abp-menuitem": true, "abp-bottombar-container": true}; | 335 let specialElements = {"abp-status-popup": true, "abp-status": true, "abp-to olbarbutton": true, "abp-menuitem": true, "abp-bottombar-container": true}; |
| 336 | 336 |
| 337 this.overlay = {all: []}; | 337 this.overlay = {all: []}; |
| 338 | 338 |
| 339 // Remove whitespace text nodes | 339 // Remove whitespace text nodes |
| 340 let walker = root.ownerDocument.createTreeWalker( | 340 let walker = root.ownerDocument.createTreeWalker( |
| 341 root, Ci.nsIDOMNodeFilter.SHOW_TEXT, | 341 root, Ci.nsIDOMNodeFilter.SHOW_TEXT, |
| 342 function(node) !/\S/.test(node.nodeValue), false | 342 (node) => !/\S/.test(node.nodeValue), false |
| 343 ); | 343 ); |
| 344 let whitespaceNodes = []; | 344 let whitespaceNodes = []; |
| 345 while (walker.nextNode()) | 345 while (walker.nextNode()) |
| 346 whitespaceNodes.push(walker.currentNode); | 346 whitespaceNodes.push(walker.currentNode); |
| 347 | 347 |
| 348 for (let i = 0; i < whitespaceNodes.length; i++) | 348 for (let i = 0; i < whitespaceNodes.length; i++) |
| 349 whitespaceNodes[i].parentNode.removeChild(whitespaceNodes[i]); | 349 whitespaceNodes[i].parentNode.removeChild(whitespaceNodes[i]); |
| 350 | 350 |
| 351 // Put overlay elements into appropriate fields | 351 // Put overlay elements into appropriate fields |
| 352 while (root.firstElementChild) | 352 while (root.firstElementChild) |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 452 }.bind(this)); | 452 }.bind(this)); |
| 453 FilterNotifier.addListener(function(action) | 453 FilterNotifier.addListener(function(action) |
| 454 { | 454 { |
| 455 if (/^(filter|subscription)\.(added|removed|disabled|updated)$/.test(actio n) || action == "load") | 455 if (/^(filter|subscription)\.(added|removed|disabled|updated)$/.test(actio n) || action == "load") |
| 456 this.updateState(); | 456 this.updateState(); |
| 457 }.bind(this)); | 457 }.bind(this)); |
| 458 | 458 |
| 459 notificationTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); | 459 notificationTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); |
| 460 notificationTimer.initWithCallback(this.showNextNotification.bind(this), | 460 notificationTimer.initWithCallback(this.showNextNotification.bind(this), |
| 461 3 * 60 * 1000, Ci.nsITimer.TYPE_ONE_SHOT) ; | 461 3 * 60 * 1000, Ci.nsITimer.TYPE_ONE_SHOT) ; |
| 462 onShutdown.add(function() notificationTimer.cancel()); | 462 onShutdown.add(() => notificationTimer.cancel()); |
| 463 | 463 |
| 464 // Add "anti-adblock messages" notification | 464 // Add "anti-adblock messages" notification |
| 465 initAntiAdblockNotification(); | 465 initAntiAdblockNotification(); |
| 466 | 466 |
| 467 let documentCreationObserver = { | 467 let documentCreationObserver = { |
| 468 observe: function(subject, topic, data) | 468 observe: function(subject, topic, data) |
| 469 { | 469 { |
| 470 if (!(subject instanceof Ci.nsIDOMWindow)) | 470 if (!(subject instanceof Ci.nsIDOMWindow)) |
| 471 return; | 471 return; |
| 472 | 472 |
| (...skipping 285 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(function(subscription) subscription.url == Prefs.subscriptions_exceptionsurl || subscription.url in privacySubscription s)) | 768 if (FilterStorage.subscriptions.some(subscription => subscription.url == Pre fs.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(function(subscription) subscription ins tanceof DownloadableSubscription && subscription.url != Prefs.subscriptions_exce ptionsurl)) | 773 if (FilterStorage.subscriptions.some(subscription => subscription instanceof DownloadableSubscription && subscription.url != Prefs.subscriptions_exceptionsu rl)) |
| 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(function(subscription) subscription.u rl != Prefs.subscriptions_exceptionsurl && subscription.filters.length)) | 779 if (FilterStorage.subscriptions.some(subscription => subscription.url != P refs.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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1132 Prefs[pref] = !Prefs[pref]; | 1132 Prefs[pref] = !Prefs[pref]; |
| 1133 }, | 1133 }, |
| 1134 | 1134 |
| 1135 /** | 1135 /** |
| 1136 * If the given filter is already in user's list, removes it from the list. Ot herwise adds it. | 1136 * If the given filter is already in user's list, removes it from the list. Ot herwise adds it. |
| 1137 */ | 1137 */ |
| 1138 toggleFilter: function(/**Filter*/ filter) | 1138 toggleFilter: function(/**Filter*/ filter) |
| 1139 { | 1139 { |
| 1140 if (filter.subscriptions.length) | 1140 if (filter.subscriptions.length) |
| 1141 { | 1141 { |
| 1142 if (filter.disabled || filter.subscriptions.some(function(subscription) !( subscription instanceof SpecialSubscription))) | 1142 if (filter.disabled || filter.subscriptions.some(subscription => !(subscri ption instanceof SpecialSubscription))) |
| 1143 filter.disabled = !filter.disabled; | 1143 filter.disabled = !filter.disabled; |
| 1144 else | 1144 else |
| 1145 FilterStorage.removeFilter(filter); | 1145 FilterStorage.removeFilter(filter); |
| 1146 } | 1146 } |
| 1147 else | 1147 else |
| 1148 FilterStorage.addFilter(filter); | 1148 FilterStorage.addFilter(filter); |
| 1149 }, | 1149 }, |
| 1150 | 1150 |
| 1151 | 1151 |
| 1152 /** | 1152 /** |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1168 }, | 1168 }, |
| 1169 | 1169 |
| 1170 /** | 1170 /** |
| 1171 * Sets the current filter subscription in a single-subscription scenario, | 1171 * Sets the current filter subscription in a single-subscription scenario, |
| 1172 * all other subscriptions will be removed. | 1172 * all other subscriptions will be removed. |
| 1173 */ | 1173 */ |
| 1174 setSubscription: function(url, title) | 1174 setSubscription: function(url, title) |
| 1175 { | 1175 { |
| 1176 let subscription = Subscription.fromURL(url); | 1176 let subscription = Subscription.fromURL(url); |
| 1177 let currentSubscriptions = FilterStorage.subscriptions.filter( | 1177 let currentSubscriptions = FilterStorage.subscriptions.filter( |
| 1178 function(subscription) subscription instanceof DownloadableSubscription && subscription.url != Prefs.subscriptions_exceptionsurl | 1178 subscription => subscription instanceof DownloadableSubscription && subscr iption.url != Prefs.subscriptions_exceptionsurl |
| 1179 ); | 1179 ); |
| 1180 if (!subscription || currentSubscriptions.indexOf(subscription) >= 0) | 1180 if (!subscription || currentSubscriptions.indexOf(subscription) >= 0) |
| 1181 return; | 1181 return; |
| 1182 | 1182 |
| 1183 for (let i = 0; i < currentSubscriptions.length; i++) | 1183 for (let i = 0; i < currentSubscriptions.length; i++) |
| 1184 FilterStorage.removeSubscription(currentSubscriptions[i]); | 1184 FilterStorage.removeSubscription(currentSubscriptions[i]); |
| 1185 | 1185 |
| 1186 subscription.title = title; | 1186 subscription.title = title; |
| 1187 FilterStorage.addSubscription(subscription); | 1187 FilterStorage.addSubscription(subscription); |
| 1188 if (subscription instanceof DownloadableSubscription && !subscription.lastDo wnload) | 1188 if (subscription instanceof DownloadableSubscription && !subscription.lastDo wnload) |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1312 return true; | 1312 return true; |
| 1313 } | 1313 } |
| 1314 return false; | 1314 return false; |
| 1315 }, | 1315 }, |
| 1316 | 1316 |
| 1317 /** | 1317 /** |
| 1318 * Updates state of the icon tooltip. | 1318 * Updates state of the icon tooltip. |
| 1319 */ | 1319 */ |
| 1320 fillIconTooltip: function(/**Event*/ event, /**Window*/ window) | 1320 fillIconTooltip: function(/**Event*/ event, /**Window*/ window) |
| 1321 { | 1321 { |
| 1322 function E(id) window.document.getElementById(id); | 1322 let E = id => window.document.getElementById(id); |
| 1323 | 1323 |
| 1324 let node = window.document.tooltipNode; | 1324 let node = window.document.tooltipNode; |
| 1325 if (!node || !node.hasAttribute("tooltip")) | 1325 if (!node || !node.hasAttribute("tooltip")) |
| 1326 { | 1326 { |
| 1327 event.preventDefault(); | 1327 event.preventDefault(); |
| 1328 return; | 1328 return; |
| 1329 } | 1329 } |
| 1330 | 1330 |
| 1331 // Prevent tooltip from overlapping menu | 1331 // Prevent tooltip from overlapping menu |
| 1332 for (let id of ["abp-toolbar-popup", "abp-status-popup"]) | 1332 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")); | 1350 actionDescr.setAttribute("value", Utils.getString("action" + action + "_to oltip")); |
| 1351 | 1351 |
| 1352 let statusDescr = E("abp-tooltip-status"); | 1352 let statusDescr = E("abp-tooltip-status"); |
| 1353 let state = node.getAttribute("abpstate"); | 1353 let state = node.getAttribute("abpstate"); |
| 1354 let statusStr = Utils.getString(state + "_tooltip"); | 1354 let statusStr = Utils.getString(state + "_tooltip"); |
| 1355 if (state == "active") | 1355 if (state == "active") |
| 1356 { | 1356 { |
| 1357 let [activeSubscriptions, activeFilters] = FilterStorage.subscriptions.red uce(function([subscriptions, filters], current) | 1357 let [activeSubscriptions, activeFilters] = FilterStorage.subscriptions.red uce(function([subscriptions, filters], current) |
| 1358 { | 1358 { |
| 1359 if (current instanceof SpecialSubscription) | 1359 if (current instanceof SpecialSubscription) |
| 1360 return [subscriptions, filters + current.filters.filter(function(filte r) !filter.disabled).length]; | 1360 return [subscriptions, filters + current.filters.filter(filter => !fil ter.disabled).length]; |
| 1361 else if (!current.disabled && !(Prefs.subscriptions_exceptionscheckbox & & current.url == Prefs.subscriptions_exceptionsurl)) | 1361 else if (!current.disabled && !(Prefs.subscriptions_exceptionscheckbox & & current.url == Prefs.subscriptions_exceptionsurl)) |
| 1362 return [subscriptions + 1, filters]; | 1362 return [subscriptions + 1, filters]; |
| 1363 else | 1363 else |
| 1364 return [subscriptions, filters] | 1364 return [subscriptions, filters] |
| 1365 }, [0, 0]); | 1365 }, [0, 0]); |
| 1366 | 1366 |
| 1367 statusStr = statusStr.replace(/\?1\?/, activeSubscriptions).replace(/\?2\? /, activeFilters); | 1367 statusStr = statusStr.replace(/\?1\?/, activeSubscriptions).replace(/\?2\? /, activeFilters); |
| 1368 } | 1368 } |
| 1369 statusDescr.setAttribute("value", statusStr); | 1369 statusDescr.setAttribute("value", statusStr); |
| 1370 | 1370 |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1920 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], | 1920 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], |
| 1921 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] | 1921 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] |
| 1922 ]; | 1922 ]; |
| 1923 | 1923 |
| 1924 onShutdown.add(function() | 1924 onShutdown.add(function() |
| 1925 { | 1925 { |
| 1926 for (let window in UI.applicationWindows) | 1926 for (let window in UI.applicationWindows) |
| 1927 if (UI.isBottombarOpen(window)) | 1927 if (UI.isBottombarOpen(window)) |
| 1928 UI.toggleBottombar(window); | 1928 UI.toggleBottombar(window); |
| 1929 }); | 1929 }); |
| OLD | NEW |