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 = 1234; |
| 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 = Date.now() / 1000; |
| 210 } |
| 211 } |
188 }; | 212 }; |
189 | 213 |
190 modules.matcher = { | 214 modules.matcher = { |
191 defaultMatcher: { | 215 defaultMatcher: { |
192 matchesAny: function(url, requestType, docDomain, thirdParty) | 216 matchesAny: function(url, requestType, docDomain, thirdParty) |
193 { | 217 { |
194 var blocked = params.blockedURLs.split(","); | 218 var blocked = params.blockedURLs.split(","); |
195 if (blocked.indexOf(url) >= 0) | 219 if (blocked.indexOf(url) >= 0) |
196 return new modules.filterClasses.BlockingFilter(); | 220 return new modules.filterClasses.BlockingFilter(); |
197 else | 221 else |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 type: "message", | 323 type: "message", |
300 payload: { | 324 payload: { |
301 title: "Custom subscription", | 325 title: "Custom subscription", |
302 url: "http://example.com/custom.txt", | 326 url: "http://example.com/custom.txt", |
303 type: "add-subscription" | 327 type: "add-subscription" |
304 } | 328 } |
305 }, "*"); | 329 }, "*"); |
306 }, 1000); | 330 }, 1000); |
307 } | 331 } |
308 })(this); | 332 })(this); |
OLD | NEW |