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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 (function(global) | 18 (function(global) |
19 { | 19 { |
20 if (!global.ext) | 20 if (!global.ext) |
21 global.ext = require("ext_background"); | 21 global.ext = require("ext_background"); |
22 | 22 |
23 var Prefs = require("prefs").Prefs; | 23 var Prefs = require("prefs").Prefs; |
24 var Utils = require("utils").Utils; | 24 var Utils = require("utils").Utils; |
25 var FilterStorage = require("filterStorage").FilterStorage; | 25 var FilterStorage = require("filterStorage").FilterStorage; |
26 var FilterNotifier = require("filterNotifier").FilterNotifier; | 26 var FilterNotifier = require("filterNotifier").FilterNotifier; |
27 var defaultMatcher = require("matcher").defaultMatcher; | 27 var defaultMatcher = require("matcher").defaultMatcher; |
28 | 28 var CSSRules = require("cssRules").CSSRules; |
29 | |
29 var filterClasses = require("filterClasses"); | 30 var filterClasses = require("filterClasses"); |
30 var Filter = filterClasses.Filter; | 31 var Filter = filterClasses.Filter; |
31 var BlockingFilter = filterClasses.BlockingFilter; | 32 var BlockingFilter = filterClasses.BlockingFilter; |
32 var Synchronizer = require("synchronizer").Synchronizer; | 33 var Synchronizer = require("synchronizer").Synchronizer; |
33 | 34 |
34 var subscriptionClasses = require("subscriptionClasses"); | 35 var subscriptionClasses = require("subscriptionClasses"); |
35 var Subscription = subscriptionClasses.Subscription; | 36 var Subscription = subscriptionClasses.Subscription; |
36 var DownloadableSubscription = subscriptionClasses.DownloadableSubscription; | 37 var DownloadableSubscription = subscriptionClasses.DownloadableSubscription; |
37 var SpecialSubscription = subscriptionClasses.SpecialSubscription; | 38 var SpecialSubscription = subscriptionClasses.SpecialSubscription; |
38 | 39 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
187 sendMessage("app", "error", [result.error.toString()], sender.page); | 188 sendMessage("app", "error", [result.error.toString()], sender.page); |
188 else if (result.filter) | 189 else if (result.filter) |
189 FilterStorage.addFilter(result.filter); | 190 FilterStorage.addFilter(result.filter); |
190 break; | 191 break; |
191 case "filters.blocked": | 192 case "filters.blocked": |
192 var filter = defaultMatcher.matchesAny(message.url, message.requestType, | 193 var filter = defaultMatcher.matchesAny(message.url, message.requestType, |
193 message.docDomain, message.thirdParty); | 194 message.docDomain, message.thirdParty); |
194 callback(filter instanceof BlockingFilter); | 195 callback(filter instanceof BlockingFilter); |
195 break; | 196 break; |
196 case "filters.get": | 197 case "filters.get": |
198 if (message.what == "cssproperties" && "domain" in message) | |
Thomas Greiner
2015/11/03 10:57:02
This condition allows the following invalid messag
kzar
2015/11/03 14:09:51
Done.
| |
199 { | |
200 callback(CSSRules.getRulesForDomain( | |
Thomas Greiner
2015/11/03 10:57:02
Please avoid forcing everything into a single stat
kzar
2015/11/03 14:09:51
I thought it was pretty readable as it was but fai
Thomas Greiner
2015/11/03 14:26:01
Thanks, I appreciate it. It would've even allowed
kzar
2015/11/03 15:49:49
Done.
| |
201 message.domain, message.specificOnly).map(function(filter) | |
Thomas Greiner
2015/11/03 10:57:03
The content script doesn't know whether it's suppo
kzar
2015/11/03 14:09:51
Done.
| |
202 { | |
203 return { | |
204 prefix: filter.selectorPrefix, | |
205 suffix: filter.selectorSuffix, | |
206 regexp: filter.regexpString() | |
Thomas Greiner
2015/11/03 10:57:03
`CSSPropertyFilter.prototype.regexpString` is a st
kzar
2015/11/03 14:09:51
Whoops good point, Done.
| |
207 }; | |
208 }) | |
209 ); | |
210 break; | |
211 } | |
212 | |
197 var subscription = Subscription.fromURL(message.subscriptionUrl); | 213 var subscription = Subscription.fromURL(message.subscriptionUrl); |
198 if (!subscription) | 214 if (!subscription) |
199 { | 215 { |
200 callback([]); | 216 callback([]); |
201 break; | 217 break; |
202 } | 218 } |
203 | 219 |
204 callback(subscription.filters.map(convertFilter)); | 220 callback(subscription.filters.map(convertFilter)); |
205 break; | 221 break; |
206 case "filters.importRaw": | 222 case "filters.importRaw": |
207 var result = require("filterValidation").parseFilters(message.text); | 223 var result = require("filterValidation").parseFilters(message.text); |
208 var errors = []; | 224 var errors = []; |
209 for (var i = 0; i < result.errors.length; i++) | 225 for (var i = 0; i < result.errors.length; i++) |
210 { | 226 { |
211 var error = result.errors[i]; | 227 var error = result.errors[i]; |
212 if (error.type != "unexpected-filter-list-header") | 228 if (error.type != "unexpected-filter-list-header") |
213 errors.push(error.toString()); | 229 errors.push(error.toString()); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
316 subscription.title = message.title; | 332 subscription.title = message.title; |
317 subscription.homepage = message.homepage; | 333 subscription.homepage = message.homepage; |
318 FilterStorage.addSubscription(subscription); | 334 FilterStorage.addSubscription(subscription); |
319 if (!subscription.lastDownload) | 335 if (!subscription.lastDownload) |
320 Synchronizer.execute(subscription); | 336 Synchronizer.execute(subscription); |
321 } | 337 } |
322 break; | 338 break; |
323 } | 339 } |
324 }); | 340 }); |
325 })(this); | 341 })(this); |
OLD | NEW |