| 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 | 
| 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
| 12  * GNU General Public License for more details. | 12  * GNU General Public License for more details. | 
| 13  * | 13  * | 
| 14  * You should have received a copy of the GNU General Public License | 14  * You should have received a copy of the GNU General Public License | 
| 15  * along with Adblock Plus.  If not, see <http://www.gnu.org/licenses/>. | 15  * along with Adblock Plus.  If not, see <http://www.gnu.org/licenses/>. | 
| 16  */ | 16  */ | 
| 17 | 17 | 
| 18 "use strict"; | 18 "use strict"; | 
| 19 | 19 | 
| 20 (function() | 20 (function() | 
| 21 { | 21 { | 
| 22   // Load subscriptions for features |  | 
| 23   var featureSubscriptions = [ |  | 
| 24     { |  | 
| 25       feature: "malware", |  | 
| 26       homepage: "http://malwaredomains.com/", |  | 
| 27       title: "Malware Domains", |  | 
| 28       url: "https://easylist-downloads.adblockplus.org/malwaredomains_full.txt" |  | 
| 29     }, |  | 
| 30     { |  | 
| 31       feature: "social", |  | 
| 32       homepage: "https://www.fanboy.co.nz/", |  | 
| 33       title: "Fanboy's Social Blocking List", |  | 
| 34       url: "https://easylist-downloads.adblockplus.org/fanboy-social.txt" |  | 
| 35     }, |  | 
| 36     { |  | 
| 37       feature: "tracking", |  | 
| 38       homepage: "https://easylist.adblockplus.org/", |  | 
| 39       title: "EasyPrivacy", |  | 
| 40       url: "https://easylist-downloads.adblockplus.org/easyprivacy.txt" |  | 
| 41     } |  | 
| 42   ]; |  | 
| 43 |  | 
| 44   function onDOMLoaded() | 22   function onDOMLoaded() | 
| 45   { | 23   { | 
| 46     // Set up logo image | 24     // Set up logo image | 
| 47     var logo = E("logo"); | 25     var logo = E("logo"); | 
| 48     logo.src = "skin/abp-128.png"; | 26     logo.src = "skin/abp-128.png"; | 
| 49     var errorCallback = function() | 27     var errorCallback = function() | 
| 50     { | 28     { | 
| 51       logo.removeEventListener("error", errorCallback, false); | 29       logo.removeEventListener("error", errorCallback, false); | 
| 52       // We are probably in Chrome/Opera/Safari, the image has a different path. | 30       // We are probably in Chrome/Opera/Safari, the image has a different path. | 
| 53       logo.src = "icons/detailed/abp-128.png"; | 31       logo.src = "icons/detailed/abp-128.png"; | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
| 84       if (issues.filterlistsReinitialized) | 62       if (issues.filterlistsReinitialized) | 
| 85       { | 63       { | 
| 86         E("filterlistsReinitializedWarning").removeAttribute("hidden"); | 64         E("filterlistsReinitializedWarning").removeAttribute("hidden"); | 
| 87         setLinks("filterlistsReinitializedWarning", openFilters); | 65         setLinks("filterlistsReinitializedWarning", openFilters); | 
| 88       } | 66       } | 
| 89 | 67 | 
| 90       if (issues.legacySafariVersion) | 68       if (issues.legacySafariVersion) | 
| 91         E("legacySafariWarning").removeAttribute("hidden"); | 69         E("legacySafariWarning").removeAttribute("hidden"); | 
| 92     }); | 70     }); | 
| 93 | 71 | 
| 94     // Set up feature buttons linked to subscriptions |  | 
| 95     featureSubscriptions.forEach(initToggleSubscriptionButton); |  | 
| 96     updateToggleButtons(); |  | 
| 97     updateSocialLinks(); | 72     updateSocialLinks(); | 
| 98 | 73 | 
| 99     ext.onMessage.addListener(function(message) | 74     ext.onMessage.addListener(function(message) | 
| 100     { | 75     { | 
| 101       if (message.type == "subscriptions.respond") | 76       if (message.type == "subscriptions.respond") | 
| 102       { | 77       { | 
| 103         updateToggleButtons(); |  | 
| 104         updateSocialLinks(); | 78         updateSocialLinks(); | 
| 105       } | 79       } | 
| 106     }); | 80     }); | 
| 107     ext.backgroundPage.sendMessage({ | 81     ext.backgroundPage.sendMessage({ | 
| 108       type: "subscriptions.listen", | 82       type: "subscriptions.listen", | 
| 109       filter: ["added", "removed", "updated", "disabled"] | 83       filter: ["added", "removed", "updated", "disabled"] | 
| 110     }); | 84     }); | 
| 111   } | 85   } | 
| 112 | 86 | 
| 113   function initToggleSubscriptionButton(featureSubscription) |  | 
| 114   { |  | 
| 115     var feature = featureSubscription.feature; |  | 
| 116 |  | 
| 117     var element = E("toggle-" + feature); |  | 
| 118     element.addEventListener("click", function(event) |  | 
| 119     { |  | 
| 120       ext.backgroundPage.sendMessage({ |  | 
| 121         type: "subscriptions.toggle", |  | 
| 122         url: featureSubscription.url, |  | 
| 123         title: featureSubscription.title, |  | 
| 124         homepage: featureSubscription.homepage |  | 
| 125       }); |  | 
| 126     }, false); |  | 
| 127   } |  | 
| 128 |  | 
| 129   function updateSocialLinks() | 87   function updateSocialLinks() | 
| 130   { | 88   { | 
| 131     var networks = ["twitter", "facebook", "gplus"]; | 89     var networks = ["twitter", "facebook", "gplus"]; | 
| 132     networks.forEach(function(network) | 90     networks.forEach(function(network) | 
| 133     { | 91     { | 
| 134       var link = E("share-" + network); | 92       var link = E("share-" + network); | 
| 135       checkShareResource(link.getAttribute("data-script"), function(isBlocked) | 93       checkShareResource(link.getAttribute("data-script"), function(isBlocked) | 
| 136       { | 94       { | 
| 137         // Don't open the share page if the sharing script would be blocked | 95         // Don't open the share page if the sharing script would be blocked | 
| 138         if (isBlocked) | 96         if (isBlocked) | 
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 179         links[i].addEventListener("click", arguments[i + 1], false); | 137         links[i].addEventListener("click", arguments[i + 1], false); | 
| 180       } | 138       } | 
| 181     } | 139     } | 
| 182   } | 140   } | 
| 183 | 141 | 
| 184   function openFilters() | 142   function openFilters() | 
| 185   { | 143   { | 
| 186     ext.backgroundPage.sendMessage({type: "app.open", what: "options"}); | 144     ext.backgroundPage.sendMessage({type: "app.open", what: "options"}); | 
| 187   } | 145   } | 
| 188 | 146 | 
| 189   function updateToggleButtons() |  | 
| 190   { |  | 
| 191     ext.backgroundPage.sendMessage({ |  | 
| 192       type: "subscriptions.get", |  | 
| 193       downloadable: true, |  | 
| 194       ignoreDisabled: true |  | 
| 195     }, function(subscriptions) |  | 
| 196     { |  | 
| 197       var known = Object.create(null); |  | 
| 198       for (var i = 0; i < subscriptions.length; i++) |  | 
| 199         known[subscriptions[i].url] = true; |  | 
| 200       for (var i = 0; i < featureSubscriptions.length; i++) |  | 
| 201       { |  | 
| 202         var featureSubscription = featureSubscriptions[i]; |  | 
| 203         updateToggleButton(featureSubscription.feature, featureSubscription.url 
     in known); |  | 
| 204       } |  | 
| 205     }); |  | 
| 206   } |  | 
| 207 |  | 
| 208   function updateToggleButton(feature, isEnabled) |  | 
| 209   { |  | 
| 210     var button = E("toggle-" + feature); |  | 
| 211     if (isEnabled) |  | 
| 212       button.classList.remove("off"); |  | 
| 213     else |  | 
| 214       button.classList.add("off"); |  | 
| 215   } |  | 
| 216 |  | 
| 217   document.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 147   document.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 
| 218 })(); | 148 })(); | 
| OLD | NEW | 
|---|