| LEFT | RIGHT | 
|---|
| 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 | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 24       var params = window.location.search.substr(1).split("&"); | 24       var params = window.location.search.substr(1).split("&"); | 
| 25       for (var i = 0; i < params.length; i++) | 25       for (var i = 0; i < params.length; i++) | 
| 26       { | 26       { | 
| 27         var parts = params[i].split("=", 2); | 27         var parts = params[i].split("=", 2); | 
| 28         if (parts.length == 2 && parts[0] in data) | 28         if (parts.length == 2 && parts[0] in data) | 
| 29           data[parts[0]] = decodeURIComponent(parts[1]); | 29           data[parts[0]] = decodeURIComponent(parts[1]); | 
| 30       } | 30       } | 
| 31     } | 31     } | 
| 32   } | 32   } | 
| 33 | 33 | 
|  | 34   var params = { | 
|  | 35     blockedURLs: "", | 
|  | 36     seenDataCorruption: false, | 
|  | 37     filterlistsReinitialized: false, | 
|  | 38     addSubscription: false, | 
|  | 39     filterError: false | 
|  | 40   }; | 
|  | 41   updateFromURL(params); | 
|  | 42 | 
| 34   var modules = {}; | 43   var modules = {}; | 
| 35   global.require = function(module) | 44   global.require = function(module) | 
| 36   { | 45   { | 
| 37     return modules[module]; | 46     return modules[module]; | 
| 38   }; | 47   }; | 
| 39 | 48 | 
| 40   modules.utils = { | 49   modules.utils = { | 
| 41     Utils: { | 50     Utils: { | 
| 42       getDocLink: function(link) | 51       getDocLink: function(link) | 
| 43       { | 52       { | 
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 139       } | 148       } | 
| 140     } | 149     } | 
| 141   }; | 150   }; | 
| 142 | 151 | 
| 143   modules.filterClasses = { | 152   modules.filterClasses = { | 
| 144     BlockingFilter: function() {}, | 153     BlockingFilter: function() {}, | 
| 145     Filter: function(text) | 154     Filter: function(text) | 
| 146     { | 155     { | 
| 147       this.text = text; | 156       this.text = text; | 
| 148       this.disabled = false; | 157       this.disabled = false; | 
| 149     }, |  | 
| 150     WhitelistFilter: function(text) |  | 
| 151     { |  | 
| 152       modules.filterClasses.Filter.call(this, text); |  | 
| 153     } | 158     } | 
| 154   }; | 159   }; | 
| 155   modules.filterClasses.Filter.fromText = function(text) | 160   modules.filterClasses.Filter.fromText = function(text) | 
| 156   { | 161   { | 
| 157     if (text.indexOf("@@") == 0) |  | 
| 158       return new modules.filterClasses.WhitelistFilter(text); |  | 
| 159     return new modules.filterClasses.Filter(text); | 162     return new modules.filterClasses.Filter(text); | 
| 160   }; | 163   }; | 
| 161 | 164 | 
| 162   modules.filterValidation = | 165   modules.filterValidation = | 
| 163   { | 166   { | 
| 164     FilterParsingError: function(type, details) |  | 
| 165     { |  | 
| 166       this.type = type; |  | 
| 167       if (details) |  | 
| 168       { |  | 
| 169         if ("reason" in details) |  | 
| 170           this.reason = details.reason; |  | 
| 171         if ("selector" in details) |  | 
| 172           this.selector = details.selector; |  | 
| 173       } |  | 
| 174     }, |  | 
| 175     parseFilter: function(text) | 167     parseFilter: function(text) | 
| 176     { | 168     { | 
| 177       if (text) | 169 | 
| 178       { | 170       if (params.filterError) | 
| 179         if (text[0] == "[") | 171         return {error: "Invalid filter"}; | 
| 180           return {error: new modules.filterValidation.FilterParsingError("unexpe
     cted-filter-list-header")}; |  | 
| 181       } |  | 
| 182       return {filter: modules.filterClasses.Filter.fromText(text)}; | 172       return {filter: modules.filterClasses.Filter.fromText(text)}; | 
| 183     }, | 173     }, | 
| 184     parseFilters: function(text) | 174     parseFilters: function(text) | 
| 185     { | 175     { | 
| 186       var lines = text.split("\n"); | 176       if (params.filterError) | 
| 187       var filters = []; | 177         return {errors: ["Invalid filter"]}; | 
| 188       var errors = []; | 178       return {filters: | 
| 189 | 179               text.split("\n").map(modules.filterClasses.Filter.fromText)}; | 
| 190       for (var i = 0; i < lines.length; i++) |  | 
| 191       { |  | 
| 192         var parseResult = modules.filterValidation.parseFilter(lines[i]); |  | 
| 193         if (parseResult.error) |  | 
| 194           errors.push(parseResult.error); |  | 
| 195         else |  | 
| 196           filters.push(parseResult.filter); |  | 
| 197       } |  | 
| 198 |  | 
| 199       return {filters: filters, errors: errors}; |  | 
| 200     } | 180     } | 
| 201   }; | 181   }; | 
| 202 | 182 | 
| 203   modules.synchronizer = { | 183   modules.synchronizer = { | 
| 204     Synchronizer: {} | 184     Synchronizer: {} | 
| 205   }; | 185   }; | 
| 206 | 186 | 
| 207   modules.matcher = { | 187   modules.matcher = { | 
| 208     defaultMatcher: { | 188     defaultMatcher: { | 
| 209       matchesAny: function(url, requestType, docDomain, thirdParty) | 189       matchesAny: function(url, requestType, docDomain, thirdParty) | 
| 210       { | 190       { | 
| 211         var params = {blockedURLs: ""}; |  | 
| 212         updateFromURL(params); |  | 
| 213         var blocked = params.blockedURLs.split(","); | 191         var blocked = params.blockedURLs.split(","); | 
| 214         if (blocked.indexOf(url) >= 0) | 192         if (blocked.indexOf(url) >= 0) | 
| 215           return new modules.filterClasses.BlockingFilter(); | 193           return new modules.filterClasses.BlockingFilter(); | 
| 216         else | 194         else | 
| 217           return null; | 195           return null; | 
| 218       } | 196       } | 
| 219     } | 197     } | 
| 220   }; | 198   }; | 
| 221 | 199 | 
| 222   var notifierListeners = []; | 200   var notifierListeners = []; | 
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 292     "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt", | 270     "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt", | 
| 293     "https://easylist-downloads.adblockplus.org/exceptionrules.txt", | 271     "https://easylist-downloads.adblockplus.org/exceptionrules.txt", | 
| 294     "https://easylist-downloads.adblockplus.org/fanboy-social.txt", | 272     "https://easylist-downloads.adblockplus.org/fanboy-social.txt", | 
| 295     "~user~786254" | 273     "~user~786254" | 
| 296   ]; | 274   ]; | 
| 297   var knownSubscriptions = Object.create(null); | 275   var knownSubscriptions = Object.create(null); | 
| 298   for (var subscriptionUrl of subscriptions) | 276   for (var subscriptionUrl of subscriptions) | 
| 299     knownSubscriptions[subscriptionUrl] = modules.subscriptionClasses.Subscripti
     on.fromURL(subscriptionUrl); | 277     knownSubscriptions[subscriptionUrl] = modules.subscriptionClasses.Subscripti
     on.fromURL(subscriptionUrl); | 
| 300   var customSubscription = knownSubscriptions["~user~786254"]; | 278   var customSubscription = knownSubscriptions["~user~786254"]; | 
| 301 | 279 | 
| 302   var issues = {seenDataCorruption: false, filterlistsReinitialized: false}; | 280   global.seenDataCorruption = params.seenDataCorruption; | 
| 303   updateFromURL(issues); | 281   global.filterlistsReinitialized = params.filterlistsReinitialized; | 
| 304   global.seenDataCorruption = issues.seenDataCorruption; |  | 
| 305   global.filterlistsReinitialized = issues.filterlistsReinitialized; |  | 
| 306 | 282 | 
| 307   var events = {addSubscription: false}; | 283   if (params.addSubscription) | 
| 308   updateFromURL(events); |  | 
| 309   if (events.addSubscription) |  | 
| 310   { | 284   { | 
| 311     // We don't know how long it will take for the page to fully load | 285     // We don't know how long it will take for the page to fully load | 
| 312     // so we'll post the message after one second | 286     // so we'll post the message after one second | 
| 313     setTimeout(function() | 287     setTimeout(function() | 
| 314     { | 288     { | 
| 315       window.postMessage({ | 289       window.postMessage({ | 
| 316         type: "message", | 290         type: "message", | 
| 317         payload: { | 291         payload: { | 
| 318           title: "Custom subscription", | 292           title: "Custom subscription", | 
| 319           url: "http://example.com/custom.txt", | 293           url: "http://example.com/custom.txt", | 
| 320           type: "add-subscription" | 294           type: "add-subscription" | 
| 321         } | 295         } | 
| 322       }, "*"); | 296       }, "*"); | 
| 323     }, 1000); | 297     }, 1000); | 
| 324   } | 298   } | 
| 325 })(this); | 299 })(this); | 
| LEFT | RIGHT | 
|---|