| OLD | NEW | 
| (Empty) |  | 
 |    1 /* | 
 |    2  * This file is part of Adblock Plus <http://adblockplus.org/>, | 
 |    3  * Copyright (C) 2006-2014 Eyeo GmbH | 
 |    4  * | 
 |    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 | 
 |    7  * published by the Free Software Foundation. | 
 |    8  * | 
 |    9  * Adblock Plus is distributed in the hope that it will be useful, | 
 |   10  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
 |   11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
 |   12  * GNU General Public License for more details. | 
 |   13  * | 
 |   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/>. | 
 |   16  */ | 
 |   17  | 
 |   18 (function(global) | 
 |   19 { | 
 |   20   function getURLParameters(data) | 
 |   21   { | 
 |   22     if (window.location.search) | 
 |   23     { | 
 |   24       var params = window.location.search.substr(1).split("&"); | 
 |   25       for (var i = 0; i < params.length; i++) | 
 |   26       { | 
 |   27         var parts = params[i].split("=", 2); | 
 |   28         if (parts.length == 2 && parts[0] in data) | 
 |   29           data[parts[0]] = decodeURIComponent(parts[1]); | 
 |   30       } | 
 |   31     } | 
 |   32   } | 
 |   33  | 
 |   34   var subscriptions =[ | 
 |   35     "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt", | 
 |   36     "https://easylist-downloads.adblockplus.org/exceptionrules.txt", | 
 |   37     "https://easylist-downloads.adblockplus.org/fanboy-social.txt" | 
 |   38   ]; | 
 |   39  | 
 |   40   global.Utils = { | 
 |   41     getDocLink: function(link) | 
 |   42     { | 
 |   43       return "https://adblockplus.org/redirect?link=" + encodeURIComponent(link)
     ; | 
 |   44     } | 
 |   45   }; | 
 |   46  | 
 |   47   global.Subscription = { | 
 |   48     fromURL: function(url) | 
 |   49     { | 
 |   50       return { | 
 |   51         url: url, | 
 |   52         title: "Subscription " + url, | 
 |   53         disabled: false, | 
 |   54         lastDownload: 1234 | 
 |   55       }; | 
 |   56     } | 
 |   57   }; | 
 |   58  | 
 |   59   global.FilterStorage = { | 
 |   60     get subscriptions() | 
 |   61     { | 
 |   62       return subscriptions.map(global.Subscription.fromURL); | 
 |   63     }, | 
 |   64  | 
 |   65     get knownSubscriptions() | 
 |   66     { | 
 |   67       var result = {}; | 
 |   68       for (var i = 0; i < subscriptions.length; i++) | 
 |   69         result[subscriptions[i]] = global.Subscription.fromURL(subscriptions[i])
     ; | 
 |   70       return result; | 
 |   71     }, | 
 |   72  | 
 |   73     addSubscription: function(subscription) | 
 |   74     { | 
 |   75       var index = subscriptions.indexOf(subscription.url); | 
 |   76       if (index < 0) | 
 |   77       { | 
 |   78         subscriptions.push(subscription.url); | 
 |   79         global.FilterNotifier.triggerListeners("subscription.added", subscriptio
     n); | 
 |   80       } | 
 |   81     }, | 
 |   82  | 
 |   83     removeSubscription: function(subscription) | 
 |   84     { | 
 |   85       var index = subscriptions.indexOf(subscription.url); | 
 |   86       if (index >= 0) | 
 |   87       { | 
 |   88         subscriptions.splice(index, 1); | 
 |   89         global.FilterNotifier.triggerListeners("subscription.removed", subscript
     ion); | 
 |   90       } | 
 |   91     } | 
 |   92   }; | 
 |   93  | 
 |   94   global.BlockingFilter = function() {}; | 
 |   95  | 
 |   96   global.defaultMatcher = { | 
 |   97     matchesAny: function(url, requestType, docDomain, thirdParty) | 
 |   98     { | 
 |   99       var params = {blockedURLs: ""}; | 
 |  100       getURLParameters(params); | 
 |  101       var blocked = params.blockedURLs.split(","); | 
 |  102       if (blocked.indexOf(url) >= 0) | 
 |  103         return new global.BlockingFilter(); | 
 |  104       else | 
 |  105         return null; | 
 |  106     } | 
 |  107   }; | 
 |  108  | 
 |  109   var notifierListeners = []; | 
 |  110   global.FilterNotifier = { | 
 |  111     addListener: function(listener) | 
 |  112     { | 
 |  113       if (notifierListeners.indexOf(listener) < 0) | 
 |  114         notifierListeners.push(listener); | 
 |  115     }, | 
 |  116  | 
 |  117     removeListener: function(listener) | 
 |  118     { | 
 |  119       var index = notifierListeners.indexOf(listener); | 
 |  120       if (index >= 0) | 
 |  121         notifierListeners.splice(index, 1); | 
 |  122     }, | 
 |  123  | 
 |  124     triggerListeners: function() | 
 |  125     { | 
 |  126       var args = Array.prototype.slice.apply(arguments); | 
 |  127       var listeners = notifierListeners.slice(); | 
 |  128       for (var i = 0; i < listeners.length; i++) | 
 |  129         listeners[i].apply(null, args); | 
 |  130     } | 
 |  131   }; | 
 |  132  | 
 |  133   global.require = function(module) | 
 |  134   { | 
 |  135     if (module == "info") | 
 |  136     { | 
 |  137       var result = {platform: "gecko", platformVersion: "34.0", application: "fi
     refox", applicationVersion: "34.0"}; | 
 |  138       getURLParameters(result); | 
 |  139       return result; | 
 |  140     } | 
 |  141     else | 
 |  142       return undefined; | 
 |  143   } | 
 |  144  | 
 |  145   global.openOptions = function() | 
 |  146   { | 
 |  147     window.open("http://example.com/options.html", "_blank"); | 
 |  148   }; | 
 |  149  | 
 |  150   var issues = {seenDataCorruption: false, filterlistsReinitialized: false}; | 
 |  151   getURLParameters(issues); | 
 |  152   global.seenDataCorruption = issues.seenDataCorruption; | 
 |  153   global.filterlistsReinitialized = issues.filterlistsReinitialized; | 
 |  154 })(this); | 
| OLD | NEW |