| 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); |
| 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 == P
refs.subscriptions_exceptionsurl || subscription.url in privacySubscriptions)) |
| 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 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(function(subscription) subscription.u
rl != Prefs.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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 Prefs[pref] = !Prefs[pref]; | 1145 Prefs[pref] = !Prefs[pref]; |
| 1146 }, | 1146 }, |
| 1147 | 1147 |
| 1148 /** | 1148 /** |
| 1149 * 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. |
| 1150 */ | 1150 */ |
| 1151 toggleFilter: function(/**Filter*/ filter) | 1151 toggleFilter: function(/**Filter*/ filter) |
| 1152 { | 1152 { |
| 1153 if (filter.subscriptions.length) | 1153 if (filter.subscriptions.length) |
| 1154 { | 1154 { |
| 1155 if (filter.disabled || filter.subscriptions.some(function(subscription) !(
subscription instanceof SpecialSubscription))) | 1155 if (filter.disabled || filter.subscriptions.some((subscription) => !(subsc
ription instanceof SpecialSubscription))) |
| 1156 filter.disabled = !filter.disabled; | 1156 filter.disabled = !filter.disabled; |
| 1157 else | 1157 else |
| 1158 FilterStorage.removeFilter(filter); | 1158 FilterStorage.removeFilter(filter); |
| 1159 } | 1159 } |
| 1160 else | 1160 else |
| 1161 FilterStorage.addFilter(filter); | 1161 FilterStorage.addFilter(filter); |
| 1162 }, | 1162 }, |
| 1163 | 1163 |
| 1164 | 1164 |
| 1165 /** | 1165 /** |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1181 }, | 1181 }, |
| 1182 | 1182 |
| 1183 /** | 1183 /** |
| 1184 * Sets the current filter subscription in a single-subscription scenario, | 1184 * Sets the current filter subscription in a single-subscription scenario, |
| 1185 * all other subscriptions will be removed. | 1185 * all other subscriptions will be removed. |
| 1186 */ | 1186 */ |
| 1187 setSubscription: function(url, title) | 1187 setSubscription: function(url, title) |
| 1188 { | 1188 { |
| 1189 let subscription = Subscription.fromURL(url); | 1189 let subscription = Subscription.fromURL(url); |
| 1190 let currentSubscriptions = FilterStorage.subscriptions.filter( | 1190 let currentSubscriptions = FilterStorage.subscriptions.filter( |
| 1191 function(subscription) subscription instanceof DownloadableSubscription &&
subscription.url != Prefs.subscriptions_exceptionsurl | 1191 ((subscription) => subscription instanceof DownloadableSubscription && sub
scription.url != Prefs.subscriptions_exceptionsurl |
| 1192 ); | 1192 ); |
| 1193 if (!subscription || currentSubscriptions.indexOf(subscription) >= 0) | 1193 if (!subscription || currentSubscriptions.indexOf(subscription) >= 0) |
| 1194 return; | 1194 return; |
| 1195 | 1195 |
| 1196 for (let i = 0; i < currentSubscriptions.length; i++) | 1196 for (let i = 0; i < currentSubscriptions.length; i++) |
| 1197 FilterStorage.removeSubscription(currentSubscriptions[i]); | 1197 FilterStorage.removeSubscription(currentSubscriptions[i]); |
| 1198 | 1198 |
| 1199 subscription.title = title; | 1199 subscription.title = title; |
| 1200 FilterStorage.addSubscription(subscription); | 1200 FilterStorage.addSubscription(subscription); |
| 1201 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... |
| 1325 return true; | 1325 return true; |
| 1326 } | 1326 } |
| 1327 return false; | 1327 return false; |
| 1328 }, | 1328 }, |
| 1329 | 1329 |
| 1330 /** | 1330 /** |
| 1331 * Updates state of the icon tooltip. | 1331 * Updates state of the icon tooltip. |
| 1332 */ | 1332 */ |
| 1333 fillIconTooltip: function(/**Event*/ event, /**Window*/ window) | 1333 fillIconTooltip: function(/**Event*/ event, /**Window*/ window) |
| 1334 { | 1334 { |
| 1335 function E(id) window.document.getElementById(id); | 1335 let E = (id) => window.document.getElementById(id); |
| 1336 | 1336 |
| 1337 let node = window.document.tooltipNode; | 1337 let node = window.document.tooltipNode; |
| 1338 if (!node || !node.hasAttribute("tooltip")) | 1338 if (!node || !node.hasAttribute("tooltip")) |
| 1339 { | 1339 { |
| 1340 event.preventDefault(); | 1340 event.preventDefault(); |
| 1341 return; | 1341 return; |
| 1342 } | 1342 } |
| 1343 | 1343 |
| 1344 // Prevent tooltip from overlapping menu | 1344 // Prevent tooltip from overlapping menu |
| 1345 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... |
| 1363 actionDescr.setAttribute("value", Utils.getString("action" + action + "_to
oltip")); | 1363 actionDescr.setAttribute("value", Utils.getString("action" + action + "_to
oltip")); |
| 1364 | 1364 |
| 1365 let statusDescr = E("abp-tooltip-status"); | 1365 let statusDescr = E("abp-tooltip-status"); |
| 1366 let state = node.getAttribute("abpstate"); | 1366 let state = node.getAttribute("abpstate"); |
| 1367 let statusStr = Utils.getString(state + "_tooltip"); | 1367 let statusStr = Utils.getString(state + "_tooltip"); |
| 1368 if (state == "active") | 1368 if (state == "active") |
| 1369 { | 1369 { |
| 1370 let [activeSubscriptions, activeFilters] = FilterStorage.subscriptions.red
uce(function([subscriptions, filters], current) | 1370 let [activeSubscriptions, activeFilters] = FilterStorage.subscriptions.red
uce(function([subscriptions, filters], current) |
| 1371 { | 1371 { |
| 1372 if (current instanceof SpecialSubscription) | 1372 if (current instanceof SpecialSubscription) |
| 1373 return [subscriptions, filters + current.filters.filter(function(filte
r) !filter.disabled).length]; | 1373 return [subscriptions, filters + current.filters.filter((filter) => !f
ilter.disabled).length]; |
| 1374 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)) |
| 1375 return [subscriptions + 1, filters]; | 1375 return [subscriptions + 1, filters]; |
| 1376 else | 1376 else |
| 1377 return [subscriptions, filters] | 1377 return [subscriptions, filters] |
| 1378 }, [0, 0]); | 1378 }, [0, 0]); |
| 1379 | 1379 |
| 1380 statusStr = statusStr.replace(/\?1\?/, activeSubscriptions).replace(/\?2\?
/, activeFilters); | 1380 statusStr = statusStr.replace(/\?1\?/, activeSubscriptions).replace(/\?2\?
/, activeFilters); |
| 1381 } | 1381 } |
| 1382 statusDescr.setAttribute("value", statusStr); | 1382 statusDescr.setAttribute("value", statusStr); |
| 1383 | 1383 |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1933 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], | 1933 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], |
| 1934 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] | 1934 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] |
| 1935 ]; | 1935 ]; |
| 1936 | 1936 |
| 1937 onShutdown.add(function() | 1937 onShutdown.add(function() |
| 1938 { | 1938 { |
| 1939 for (let window in UI.applicationWindows) | 1939 for (let window in UI.applicationWindows) |
| 1940 if (UI.isBottombarOpen(window)) | 1940 if (UI.isBottombarOpen(window)) |
| 1941 UI.toggleBottombar(window); | 1941 UI.toggleBottombar(window); |
| 1942 }); | 1942 }); |
| OLD | NEW |