| 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-2015 Eyeo GmbH |    3  * Copyright (C) 2006-2015 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   function E(id) |  | 
|   23   { |  | 
|   24     return document.getElementById(id); |  | 
|   25   } |  | 
|   26  |  | 
|   27   // Load subscriptions for features |   22   // Load subscriptions for features | 
|   28   var featureSubscriptions = [ |   23   var featureSubscriptions = [ | 
|   29     { |   24     { | 
|   30       feature: "malware", |   25       feature: "malware", | 
|   31       homepage: "http://malwaredomains.com/", |   26       homepage: "http://malwaredomains.com/", | 
|   32       title: "Malware Domains", |   27       title: "Malware Domains", | 
|   33       url: "https://easylist-downloads.adblockplus.org/malwaredomains_full.txt" |   28       url: "https://easylist-downloads.adblockplus.org/malwaredomains_full.txt" | 
|   34     }, |   29     }, | 
|   35     { |   30     { | 
|   36       feature: "social", |   31       feature: "social", | 
|   37       homepage: "https://www.fanboy.co.nz/", |   32       homepage: "https://www.fanboy.co.nz/", | 
|   38       title: "Fanboy's Social Blocking List", |   33       title: "Fanboy's Social Blocking List", | 
|   39       url: "https://easylist-downloads.adblockplus.org/fanboy-social.txt" |   34       url: "https://easylist-downloads.adblockplus.org/fanboy-social.txt" | 
|   40     }, |   35     }, | 
|   41     { |   36     { | 
|   42       feature: "tracking", |   37       feature: "tracking", | 
|   43       homepage: "https://easylist.adblockplus.org/", |   38       homepage: "https://easylist.adblockplus.org/", | 
|   44       title: "EasyPrivacy", |   39       title: "EasyPrivacy", | 
|   45       url: "https://easylist-downloads.adblockplus.org/easyprivacy.txt" |   40       url: "https://easylist-downloads.adblockplus.org/easyprivacy.txt" | 
|   46     } |   41     } | 
|   47   ]; |   42   ]; | 
|   48  |   43  | 
|   49   function getDocLink(link, callback) |  | 
|   50   { |  | 
|   51     ext.backgroundPage.sendMessage({ |  | 
|   52       type: "app.get", |  | 
|   53       what: "doclink", |  | 
|   54       link: link |  | 
|   55     }, callback); |  | 
|   56   } |  | 
|   57  |  | 
|   58   function onDOMLoaded() |   44   function onDOMLoaded() | 
|   59   { |   45   { | 
|   60     // Set up logo image |   46     // Set up logo image | 
|   61     var logo = E("logo"); |   47     var logo = E("logo"); | 
|   62     logo.src = "skin/abp-128.png"; |   48     logo.src = "skin/abp-128.png"; | 
|   63     var errorCallback = function() |   49     var errorCallback = function() | 
|   64     { |   50     { | 
|   65       logo.removeEventListener("error", errorCallback, false); |   51       logo.removeEventListener("error", errorCallback, false); | 
|   66       // We are probably in Chrome/Opera/Safari, the image has a different path. |   52       // We are probably in Chrome/Opera/Safari, the image has a different path. | 
|   67       logo.src = "icons/detailed/abp-128.png"; |   53       logo.src = "icons/detailed/abp-128.png"; | 
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  143     { |  129     { | 
|  144       ext.backgroundPage.sendMessage({ |  130       ext.backgroundPage.sendMessage({ | 
|  145         type: "subscriptions.toggle", |  131         type: "subscriptions.toggle", | 
|  146         url: featureSubscription.url, |  132         url: featureSubscription.url, | 
|  147         title: featureSubscription.title, |  133         title: featureSubscription.title, | 
|  148         homepage: featureSubscription.homepage |  134         homepage: featureSubscription.homepage | 
|  149       }); |  135       }); | 
|  150     }, false); |  136     }, false); | 
|  151   } |  137   } | 
|  152  |  138  | 
|  153   function openSharePopup(url) |  | 
|  154   { |  | 
|  155     var iframe = E("share-popup"); |  | 
|  156     var glassPane = E("glass-pane"); |  | 
|  157     var popupMessageReceived = false; |  | 
|  158  |  | 
|  159     var popupMessageListener = function(event) |  | 
|  160     { |  | 
|  161       if (!/[.\/]adblockplus\.org$/.test(event.origin)) |  | 
|  162         return; |  | 
|  163  |  | 
|  164       var width = event.data.width; |  | 
|  165       var height = event.data.height; |  | 
|  166       iframe.width = width; |  | 
|  167       iframe.height = height; |  | 
|  168       iframe.style.marginTop = -height/2 + "px"; |  | 
|  169       iframe.style.marginLeft = -width/2 + "px"; |  | 
|  170       popupMessageReceived = true; |  | 
|  171       window.removeEventListener("message", popupMessageListener); |  | 
|  172     }; |  | 
|  173     // Firefox requires last parameter to be true to be triggered by unprivilege
     d pages |  | 
|  174     window.addEventListener("message", popupMessageListener, false, true); |  | 
|  175  |  | 
|  176     var popupLoadListener = function() |  | 
|  177     { |  | 
|  178       if (popupMessageReceived) |  | 
|  179       { |  | 
|  180         iframe.className = "visible"; |  | 
|  181  |  | 
|  182         var popupCloseListener = function() |  | 
|  183         { |  | 
|  184           iframe.className = glassPane.className = ""; |  | 
|  185           document.removeEventListener("click", popupCloseListener); |  | 
|  186         }; |  | 
|  187         document.addEventListener("click", popupCloseListener, false); |  | 
|  188       } |  | 
|  189       else |  | 
|  190       { |  | 
|  191         glassPane.className = ""; |  | 
|  192         window.removeEventListener("message", popupMessageListener); |  | 
|  193       } |  | 
|  194  |  | 
|  195       iframe.removeEventListener("load", popupLoadListener); |  | 
|  196     }; |  | 
|  197     iframe.addEventListener("load", popupLoadListener, false); |  | 
|  198  |  | 
|  199     iframe.src = url; |  | 
|  200     glassPane.className = "visible"; |  | 
|  201   } |  | 
|  202  |  | 
|  203   function updateSocialLinks() |  139   function updateSocialLinks() | 
|  204   { |  140   { | 
|  205     var networks = ["twitter", "facebook", "gplus"]; |  141     var networks = ["twitter", "facebook", "gplus"]; | 
|  206     networks.forEach(function(network) |  142     networks.forEach(function(network) | 
|  207     { |  143     { | 
|  208       var link = E("share-" + network); |  144       var link = E("share-" + network); | 
|  209       var message = { |  145       checkShareResource(link.getAttribute("data-script"), function(isBlocked) | 
|  210         type: "filters.blocked", |  | 
|  211         url: link.getAttribute("data-script"), |  | 
|  212         requestType: "SCRIPT", |  | 
|  213         docDomain: "adblockplus.org", |  | 
|  214         thirdParty: true |  | 
|  215       }; |  | 
|  216       ext.backgroundPage.sendMessage(message, function(blocked) |  | 
|  217       { |  146       { | 
|  218         // Don't open the share page if the sharing script would be blocked |  147         // Don't open the share page if the sharing script would be blocked | 
|  219         if (blocked) |  148         if (isBlocked) | 
|  220           link.removeEventListener("click", onSocialLinkClick, false); |  149           link.removeEventListener("click", onSocialLinkClick, false); | 
|  221         else |  150         else | 
|  222           link.addEventListener("click", onSocialLinkClick, false); |  151           link.addEventListener("click", onSocialLinkClick, false); | 
|  223       }); |  152       }); | 
|  224     }); |  153     }); | 
|  225   } |  154   } | 
|  226  |  155  | 
|  227   function onSocialLinkClick(event) |  156   function onSocialLinkClick(event) | 
|  228   { |  157   { | 
|  229     event.preventDefault(); |  158     event.preventDefault(); | 
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  287   { |  216   { | 
|  288     var button = E("toggle-" + feature); |  217     var button = E("toggle-" + feature); | 
|  289     if (isEnabled) |  218     if (isEnabled) | 
|  290       button.classList.remove("off"); |  219       button.classList.remove("off"); | 
|  291     else |  220     else | 
|  292       button.classList.add("off"); |  221       button.classList.add("off"); | 
|  293   } |  222   } | 
|  294  |  223  | 
|  295   document.addEventListener("DOMContentLoaded", onDOMLoaded, false); |  224   document.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 
|  296 })(); |  225 })(); | 
| OLD | NEW |