| Left: | ||
| Right: |
| 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 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 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 = { | 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 }; | 41 }; |
| 41 updateFromURL(params); | 42 updateFromURL(params); |
| 42 | 43 |
| 43 var modules = {}; | 44 var modules = {}; |
| 44 global.require = function(module) | 45 global.require = function(module) |
| 45 { | 46 { |
| 46 return modules[module]; | 47 return modules[module]; |
| 47 }; | 48 }; |
| 48 | 49 |
| 49 modules.utils = { | 50 modules.utils = { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 64 "subscriptions_exceptionsurl": "https://easylist-downloads.adblockplus.org /exceptionrules.txt" | 65 "subscriptions_exceptionsurl": "https://easylist-downloads.adblockplus.org /exceptionrules.txt" |
| 65 } | 66 } |
| 66 }; | 67 }; |
| 67 | 68 |
| 68 modules.subscriptionClasses = { | 69 modules.subscriptionClasses = { |
| 69 Subscription: function(url) | 70 Subscription: function(url) |
| 70 { | 71 { |
| 71 this.url = url; | 72 this.url = url; |
| 72 this.title = "Subscription " + url; | 73 this.title = "Subscription " + url; |
| 73 this.disabled = false; | 74 this.disabled = false; |
| 74 this.lastDownload = 1234; | 75 this._lastDownload = 0; |
| 76 this.homepage = "https://easylist.adblockplus.org/"; | |
| 77 this.downloadStatus = params.downloadStatus; | |
| 75 }, | 78 }, |
| 76 | 79 |
| 77 SpecialSubscription: function(url) | 80 SpecialSubscription: function(url) |
| 78 { | 81 { |
| 79 this.url = url; | 82 this.url = url; |
| 80 this.disabled = false; | 83 this.disabled = false; |
| 81 this.filters = knownFilters.slice(); | 84 this.filters = knownFilters.slice(); |
| 82 } | 85 } |
| 83 }; | 86 }; |
| 84 modules.subscriptionClasses.Subscription.fromURL = function(url) | 87 modules.subscriptionClasses.Subscription.fromURL = function(url) |
| 85 { | 88 { |
| 89 if (url in knownSubscriptions) | |
| 90 return knownSubscriptions[url]; | |
| 91 | |
| 86 if (/^https?:\/\//.test(url)) | 92 if (/^https?:\/\//.test(url)) |
| 87 return new modules.subscriptionClasses.Subscription(url); | 93 return new modules.subscriptionClasses.Subscription(url); |
| 88 else | 94 else |
| 89 return new modules.subscriptionClasses.SpecialSubscription(url); | 95 return new modules.subscriptionClasses.SpecialSubscription(url); |
| 90 }; | 96 }; |
| 91 modules.subscriptionClasses.DownloadableSubscription = modules.subscriptionCla sses.Subscription; | 97 modules.subscriptionClasses.DownloadableSubscription = modules.subscriptionCla sses.Subscription; |
| 92 | 98 |
| 99 modules.subscriptionClasses.Subscription.prototype = | |
| 100 { | |
| 101 get lastDownload() | |
| 102 { | |
| 103 return this._lastDownload; | |
| 104 }, | |
| 105 set lastDownload(value) | |
| 106 { | |
| 107 this._lastDownload = value; | |
| 108 modules.filterNotifier.FilterNotifier.triggerListeners("subscription.lastD ownload", this); | |
| 109 } | |
| 110 }; | |
| 111 | |
| 93 modules.filterStorage = { | 112 modules.filterStorage = { |
| 94 FilterStorage: { | 113 FilterStorage: { |
| 95 get subscriptions() | 114 get subscriptions() |
| 96 { | 115 { |
| 97 var subscriptions = []; | 116 var subscriptions = []; |
| 98 for (var url in modules.filterStorage.FilterStorage.knownSubscriptions) | 117 for (var url in modules.filterStorage.FilterStorage.knownSubscriptions) |
| 99 subscriptions.push(modules.filterStorage.FilterStorage.knownSubscripti ons[url]); | 118 subscriptions.push(modules.filterStorage.FilterStorage.knownSubscripti ons[url]); |
| 100 return subscriptions; | 119 return subscriptions; |
| 101 }, | 120 }, |
| 102 | 121 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 return { | 196 return { |
| 178 filters: text.split("\n") | 197 filters: text.split("\n") |
| 179 .filter(function(filter) {return !!filter;}) | 198 .filter(function(filter) {return !!filter;}) |
| 180 .map(modules.filterClasses.Filter.fromText), | 199 .map(modules.filterClasses.Filter.fromText), |
| 181 errors: [] | 200 errors: [] |
| 182 }; | 201 }; |
| 183 } | 202 } |
| 184 }; | 203 }; |
| 185 | 204 |
| 186 modules.synchronizer = { | 205 modules.synchronizer = { |
| 187 Synchronizer: {} | 206 Synchronizer: { |
| 207 execute: function(subscription, manual) | |
| 208 { | |
| 209 subscription.lastDownload = 0; | |
| 210 setTimeout(function() | |
| 211 { | |
| 212 subscription.lastDownload = Date.now() / 1000; | |
| 213 }, 500); | |
| 214 } | |
| 215 } | |
| 188 }; | 216 }; |
| 189 | 217 |
| 190 modules.matcher = { | 218 modules.matcher = { |
| 191 defaultMatcher: { | 219 defaultMatcher: { |
| 192 matchesAny: function(url, requestType, docDomain, thirdParty) | 220 matchesAny: function(url, requestType, docDomain, thirdParty) |
| 193 { | 221 { |
| 194 var blocked = params.blockedURLs.split(","); | 222 var blocked = params.blockedURLs.split(","); |
| 195 if (blocked.indexOf(url) >= 0) | 223 if (blocked.indexOf(url) >= 0) |
| 196 return new modules.filterClasses.BlockingFilter(); | 224 return new modules.filterClasses.BlockingFilter(); |
| 197 else | 225 else |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 var knownFilters = filters.map(modules.filterClasses.Filter.fromText); | 304 var knownFilters = filters.map(modules.filterClasses.Filter.fromText); |
| 277 | 305 |
| 278 var subscriptions = [ | 306 var subscriptions = [ |
| 279 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt", | 307 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt", |
| 280 "https://easylist-downloads.adblockplus.org/exceptionrules.txt", | 308 "https://easylist-downloads.adblockplus.org/exceptionrules.txt", |
| 281 "https://easylist-downloads.adblockplus.org/fanboy-social.txt", | 309 "https://easylist-downloads.adblockplus.org/fanboy-social.txt", |
| 282 "~user~786254" | 310 "~user~786254" |
| 283 ]; | 311 ]; |
| 284 var knownSubscriptions = Object.create(null); | 312 var knownSubscriptions = Object.create(null); |
| 285 for (var subscriptionUrl of subscriptions) | 313 for (var subscriptionUrl of subscriptions) |
| 314 { | |
| 286 knownSubscriptions[subscriptionUrl] = modules.subscriptionClasses.Subscripti on.fromURL(subscriptionUrl); | 315 knownSubscriptions[subscriptionUrl] = modules.subscriptionClasses.Subscripti on.fromURL(subscriptionUrl); |
| 316 knownSubscriptions[subscriptionUrl].lastDownload = 1234; | |
|
Thomas Greiner
2016/02/04 15:28:16
This will trigger the "subscriptions.lastDownload"
saroyanm
2016/02/04 17:50:06
Done.
| |
| 317 } | |
| 287 var customSubscription = knownSubscriptions["~user~786254"]; | 318 var customSubscription = knownSubscriptions["~user~786254"]; |
| 288 | 319 |
| 289 global.seenDataCorruption = params.seenDataCorruption; | 320 global.seenDataCorruption = params.seenDataCorruption; |
| 290 global.filterlistsReinitialized = params.filterlistsReinitialized; | 321 global.filterlistsReinitialized = params.filterlistsReinitialized; |
| 291 | 322 |
| 292 if (params.addSubscription) | 323 if (params.addSubscription) |
| 293 { | 324 { |
| 294 // We don't know how long it will take for the page to fully load | 325 // We don't know how long it will take for the page to fully load |
| 295 // so we'll post the message after one second | 326 // so we'll post the message after one second |
| 296 setTimeout(function() | 327 setTimeout(function() |
| 297 { | 328 { |
| 298 window.postMessage({ | 329 window.postMessage({ |
| 299 type: "message", | 330 type: "message", |
| 300 payload: { | 331 payload: { |
| 301 title: "Custom subscription", | 332 title: "Custom subscription", |
| 302 url: "http://example.com/custom.txt", | 333 url: "http://example.com/custom.txt", |
| 303 type: "add-subscription" | 334 type: "add-subscription" |
| 304 } | 335 } |
| 305 }, "*"); | 336 }, "*"); |
| 306 }, 1000); | 337 }, 1000); |
| 307 } | 338 } |
| 308 })(this); | 339 })(this); |
| OLD | NEW |