 Issue 29333819:
  Issue 2375 - Implement "Blocking lists" section in new options page  (Closed)
    
  
    Issue 29333819:
  Issue 2375 - Implement "Blocking lists" section in new options page  (Closed) 
  | Left: | ||
| Right: | 
| 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-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 | 
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 } | 30 } | 
| 31 } | 31 } | 
| 32 } | 32 } | 
| 33 | 33 | 
| 34 var params = { | 34 var params = { | 
| 35 blockedURLs: "", | 35 blockedURLs: "", | 
| 36 seenDataCorruption: false, | 36 seenDataCorruption: false, | 
| 37 filterlistsReinitialized: false, | 37 filterlistsReinitialized: false, | 
| 38 addSubscription: false, | 38 addSubscription: false, | 
| 39 filterError: false, | 39 filterError: false, | 
| 40 downloadStatus: "synchronize_ok", | 40 downloadStatus: "synchronize_ok" | 
| 41 lastDownload: 1234 | |
| 42 }; | 41 }; | 
| 43 updateFromURL(params); | 42 updateFromURL(params); | 
| 44 | 43 | 
| 45 var modules = {}; | 44 var modules = {}; | 
| 46 global.require = function(module) | 45 global.require = function(module) | 
| 47 { | 46 { | 
| 48 return modules[module]; | 47 return modules[module]; | 
| 49 }; | 48 }; | 
| 50 | 49 | 
| 51 modules.utils = { | 50 modules.utils = { | 
| (...skipping 14 matching lines...) Expand all Loading... | |
| 66 "subscriptions_exceptionsurl": "https://easylist-downloads.adblockplus.org /exceptionrules.txt" | 65 "subscriptions_exceptionsurl": "https://easylist-downloads.adblockplus.org /exceptionrules.txt" | 
| 67 } | 66 } | 
| 68 }; | 67 }; | 
| 69 | 68 | 
| 70 modules.subscriptionClasses = { | 69 modules.subscriptionClasses = { | 
| 71 Subscription: function(url) | 70 Subscription: function(url) | 
| 72 { | 71 { | 
| 73 this.url = url; | 72 this.url = url; | 
| 74 this.title = "Subscription " + url; | 73 this.title = "Subscription " + url; | 
| 75 this.disabled = false; | 74 this.disabled = false; | 
| 76 this._lastDownload = params.lastDownload; | 75 this._lastDownload = 1234; | 
| 77 this.homepage = "https://easylist.adblockplus.org/"; | 76 this.homepage = "https://easylist.adblockplus.org/"; | 
| 78 this.downloadStatus = params.downloadStatus; | 77 this.downloadStatus = params.downloadStatus; | 
| 
Thomas Greiner
2016/02/03 14:50:14
Please document those newly introduced parameters
 
saroyanm
2016/02/03 17:43:11
Done.
 | |
| 79 }, | 78 }, | 
| 80 | 79 | 
| 81 SpecialSubscription: function(url) | 80 SpecialSubscription: function(url) | 
| 82 { | 81 { | 
| 83 this.url = url; | 82 this.url = url; | 
| 84 this.disabled = false; | 83 this.disabled = false; | 
| 85 this.filters = knownFilters.slice(); | 84 this.filters = knownFilters.slice(); | 
| 86 } | 85 } | 
| 87 }; | 86 }; | 
| 88 modules.subscriptionClasses.Subscription.fromURL = function(url) | 87 modules.subscriptionClasses.Subscription.fromURL = function(url) | 
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 filters: text.split("\n") | 197 filters: text.split("\n") | 
| 199 .filter(function(filter) {return !!filter;}) | 198 .filter(function(filter) {return !!filter;}) | 
| 200 .map(modules.filterClasses.Filter.fromText), | 199 .map(modules.filterClasses.Filter.fromText), | 
| 201 errors: [] | 200 errors: [] | 
| 202 }; | 201 }; | 
| 203 } | 202 } | 
| 204 }; | 203 }; | 
| 205 | 204 | 
| 206 modules.synchronizer = { | 205 modules.synchronizer = { | 
| 207 Synchronizer: { | 206 Synchronizer: { | 
| 207 downloading: false, | |
| 
Thomas Greiner
2016/02/04 20:23:46
Detail: Since this is a "private" property I'd sug
 | |
| 208 execute: function(subscription, manual) | 208 execute: function(subscription, manual) | 
| 209 { | 209 { | 
| 210 subscription.lastDownload = Date.now() / 1000; | 210 subscription.lastDownload = 0; | 
| 211 modules.synchronizer.Synchronizer.downloading = true; | |
| 212 setTimeout(function() | |
| 213 { | |
| 214 modules.synchronizer.Synchronizer.downloading = false; | |
| 215 subscription.lastDownload = Date.now() / 1000; | |
| 216 }, 500); | |
| 217 }, | |
| 218 isExecuting: function(url) | |
| 219 { | |
| 220 return modules.synchronizer.Synchronizer.downloading; | |
| 211 } | 221 } | 
| 212 } | 222 } | 
| 213 }; | 223 }; | 
| 214 | 224 | 
| 215 modules.matcher = { | 225 modules.matcher = { | 
| 216 defaultMatcher: { | 226 defaultMatcher: { | 
| 217 matchesAny: function(url, requestType, docDomain, thirdParty) | 227 matchesAny: function(url, requestType, docDomain, thirdParty) | 
| 218 { | 228 { | 
| 219 var blocked = params.blockedURLs.split(","); | 229 var blocked = params.blockedURLs.split(","); | 
| 220 if (blocked.indexOf(url) >= 0) | 230 if (blocked.indexOf(url) >= 0) | 
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 | 312 | 
| 303 var subscriptions = [ | 313 var subscriptions = [ | 
| 304 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt", | 314 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt", | 
| 305 "https://easylist-downloads.adblockplus.org/exceptionrules.txt", | 315 "https://easylist-downloads.adblockplus.org/exceptionrules.txt", | 
| 306 "https://easylist-downloads.adblockplus.org/fanboy-social.txt", | 316 "https://easylist-downloads.adblockplus.org/fanboy-social.txt", | 
| 307 "~user~786254" | 317 "~user~786254" | 
| 308 ]; | 318 ]; | 
| 309 var knownSubscriptions = Object.create(null); | 319 var knownSubscriptions = Object.create(null); | 
| 310 for (var subscriptionUrl of subscriptions) | 320 for (var subscriptionUrl of subscriptions) | 
| 311 knownSubscriptions[subscriptionUrl] = modules.subscriptionClasses.Subscripti on.fromURL(subscriptionUrl); | 321 knownSubscriptions[subscriptionUrl] = modules.subscriptionClasses.Subscripti on.fromURL(subscriptionUrl); | 
| 322 | |
| 
Thomas Greiner
2016/02/04 20:23:45
Detail: This empty line has been added without tou
 | |
| 312 var customSubscription = knownSubscriptions["~user~786254"]; | 323 var customSubscription = knownSubscriptions["~user~786254"]; | 
| 313 | 324 | 
| 314 global.seenDataCorruption = params.seenDataCorruption; | 325 global.seenDataCorruption = params.seenDataCorruption; | 
| 315 global.filterlistsReinitialized = params.filterlistsReinitialized; | 326 global.filterlistsReinitialized = params.filterlistsReinitialized; | 
| 316 | 327 | 
| 317 if (params.addSubscription) | 328 if (params.addSubscription) | 
| 318 { | 329 { | 
| 319 // We don't know how long it will take for the page to fully load | 330 // We don't know how long it will take for the page to fully load | 
| 320 // so we'll post the message after one second | 331 // so we'll post the message after one second | 
| 321 setTimeout(function() | 332 setTimeout(function() | 
| 322 { | 333 { | 
| 323 window.postMessage({ | 334 window.postMessage({ | 
| 324 type: "message", | 335 type: "message", | 
| 325 payload: { | 336 payload: { | 
| 326 title: "Custom subscription", | 337 title: "Custom subscription", | 
| 327 url: "http://example.com/custom.txt", | 338 url: "http://example.com/custom.txt", | 
| 328 type: "add-subscription" | 339 type: "add-subscription" | 
| 329 } | 340 } | 
| 330 }, "*"); | 341 }, "*"); | 
| 331 }, 1000); | 342 }, 1000); | 
| 332 } | 343 } | 
| 333 })(this); | 344 })(this); | 
| LEFT | RIGHT |