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-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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 var filter = Filter.fromText(message.text); | 205 var filter = Filter.fromText(message.text); |
206 var subscription = null; | 206 var subscription = null; |
207 if (message.subscriptionUrl) | 207 if (message.subscriptionUrl) |
208 subscription = Subscription.fromURL(message.subscriptionUrl); | 208 subscription = Subscription.fromURL(message.subscriptionUrl); |
209 | 209 |
210 if (!subscription) | 210 if (!subscription) |
211 FilterStorage.removeFilter(filter); | 211 FilterStorage.removeFilter(filter); |
212 else | 212 else |
213 FilterStorage.removeFilter(filter, subscription, message.index); | 213 FilterStorage.removeFilter(filter, subscription, message.index); |
214 break; | 214 break; |
215 case "filters.importRaw": | |
Thomas Greiner
2015/06/30 09:23:27
It's easier to search for the right method if the
saroyanm
2015/07/08 18:25:39
Done.
| |
216 var parseFilters = require("filterValidation").parseFilters; | |
217 var result = parseFilters(message.text); | |
218 | |
219 var errors = result.errors.filter(function(e) | |
Thomas Greiner
2015/06/30 09:23:27
Please rename this variable from "e" to "error". G
saroyanm
2015/07/08 18:25:39
Done, Agree
| |
220 { | |
221 return e.type != "unexpected-filter-list-header"; | |
Thomas Greiner
2015/06/30 09:23:26
I'm aware that you didn't write this but what's th
saroyanm
2015/07/08 18:25:40
It's being fired when the the filter starts with "
Thomas Greiner
2015/07/09 11:07:54
Asked Sebastian about this and the line of reasoni
| |
222 }); | |
223 | |
224 if (errors.length > 0) | |
225 { | |
226 alert(errors.join("\n")); | |
227 return; | |
228 } | |
229 | |
230 var seenFilter = Object.create(null); | |
231 for (var i = 0; i < result.filters.length; i++) | |
232 { | |
233 var filter = result.filters[i]; | |
234 FilterStorage.addFilter(filter); | |
235 seenFilter[filter.text] = null; | |
236 } | |
237 | |
238 var remove = []; | |
239 for (var i = 0; i < FilterStorage.subscriptions.length; i++) | |
240 { | |
241 var subscription = FilterStorage.subscriptions[i]; | |
242 if (!(subscription instanceof SpecialSubscription)) | |
243 continue; | |
244 | |
245 for (var j = 0; j < subscription.filters.length; j++) | |
246 { | |
247 var filter = subscription.filters[j]; | |
248 if (filter instanceof WhitelistFilter && /^@@\|\|([^\/:]+)\^\$docume nt$/.test(filter.text)) | |
Thomas Greiner
2015/06/30 09:23:27
Beware of the 80 characters limit
saroyanm
2015/07/08 18:25:39
Done.
| |
249 continue; | |
250 | |
251 if (!(filter.text in seenFilter)) | |
252 FilterStorage.removeFilter(filter); | |
253 } | |
254 } | |
255 break; | |
256 case "parse.filter": | |
Thomas Greiner
2015/06/30 09:23:27
This name is inconsistent with the other ones whic
saroyanm
2015/07/08 18:25:40
Done.
| |
257 var parseFilter = require("filterValidation").parseFilter; | |
Thomas Greiner
2015/06/30 09:23:26
No need to require it each time it's called so ple
saroyanm
2015/07/08 18:25:40
Agree, was stupid.
| |
258 callback(parseFilter(message.text)); | |
Thomas Greiner
2015/06/30 09:23:26
"parseFilter" returns an instance of `Filter` (e.g
saroyanm
2015/07/08 18:25:39
Good point, done.
| |
259 break; | |
215 case "prefs.get": | 260 case "prefs.get": |
216 callback(Prefs[message.key]); | 261 callback(Prefs[message.key]); |
217 break; | 262 break; |
218 case "subscriptions.add": | 263 case "subscriptions.add": |
219 if (message.url in FilterStorage.knownSubscriptions) | 264 if (message.url in FilterStorage.knownSubscriptions) |
220 return; | 265 return; |
221 | 266 |
222 var subscription = Subscription.fromURL(message.url); | 267 var subscription = Subscription.fromURL(message.url); |
223 if (!subscription) | 268 if (!subscription) |
224 return; | 269 return; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 subscription.title = message.title; | 312 subscription.title = message.title; |
268 subscription.homepage = message.homepage; | 313 subscription.homepage = message.homepage; |
269 FilterStorage.addSubscription(subscription); | 314 FilterStorage.addSubscription(subscription); |
270 if (!subscription.lastDownload) | 315 if (!subscription.lastDownload) |
271 Synchronizer.execute(subscription); | 316 Synchronizer.execute(subscription); |
272 } | 317 } |
273 break; | 318 break; |
274 } | 319 } |
275 }); | 320 }); |
276 })(this); | 321 })(this); |
OLD | NEW |