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; |
| 33 var RegExpFilter = filterClasses.RegExpFilter; |
32 var Synchronizer = require("synchronizer").Synchronizer; | 34 var Synchronizer = require("synchronizer").Synchronizer; |
33 | 35 |
34 var subscriptionClasses = require("subscriptionClasses"); | 36 var subscriptionClasses = require("subscriptionClasses"); |
35 var Subscription = subscriptionClasses.Subscription; | 37 var Subscription = subscriptionClasses.Subscription; |
36 var DownloadableSubscription = subscriptionClasses.DownloadableSubscription; | 38 var DownloadableSubscription = subscriptionClasses.DownloadableSubscription; |
37 var SpecialSubscription = subscriptionClasses.SpecialSubscription; | 39 var SpecialSubscription = subscriptionClasses.SpecialSubscription; |
38 | 40 |
39 function convertObject(keys, obj) | 41 function convertObject(keys, obj) |
40 { | 42 { |
41 var result = {}; | 43 var result = {}; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 sendMessage("app", "error", [result.error.toString()], sender.page); | 189 sendMessage("app", "error", [result.error.toString()], sender.page); |
188 else if (result.filter) | 190 else if (result.filter) |
189 FilterStorage.addFilter(result.filter); | 191 FilterStorage.addFilter(result.filter); |
190 break; | 192 break; |
191 case "filters.blocked": | 193 case "filters.blocked": |
192 var filter = defaultMatcher.matchesAny(message.url, message.requestType, | 194 var filter = defaultMatcher.matchesAny(message.url, message.requestType, |
193 message.docDomain, message.thirdParty); | 195 message.docDomain, message.thirdParty); |
194 callback(filter instanceof BlockingFilter); | 196 callback(filter instanceof BlockingFilter); |
195 break; | 197 break; |
196 case "filters.get": | 198 case "filters.get": |
| 199 if (message.what == "cssproperties") |
| 200 { |
| 201 var filters = []; |
| 202 var isFrameWhitelisted = require("whitelisting").isFrameWhitelisted; |
| 203 |
| 204 if (!isFrameWhitelisted(sender.page, sender.frame, |
| 205 RegExpFilter.typeMap.DOCUMENT | |
| 206 RegExpFilter.typeMap.ELEMHIDE)) |
| 207 { |
| 208 filters = CSSRules.getRulesForDomain(sender.frame.url.hostname); |
| 209 filters = filters.map(function(filter) |
| 210 { |
| 211 return { |
| 212 prefix: filter.selectorPrefix, |
| 213 suffix: filter.selectorSuffix, |
| 214 regexp: filter.regexpString |
| 215 }; |
| 216 }); |
| 217 } |
| 218 callback(filters); |
| 219 break; |
| 220 } |
| 221 |
197 var subscription = Subscription.fromURL(message.subscriptionUrl); | 222 var subscription = Subscription.fromURL(message.subscriptionUrl); |
198 if (!subscription) | 223 if (!subscription) |
199 { | 224 { |
200 callback([]); | 225 callback([]); |
201 break; | 226 break; |
202 } | 227 } |
203 | 228 |
204 callback(subscription.filters.map(convertFilter)); | 229 callback(subscription.filters.map(convertFilter)); |
205 break; | 230 break; |
206 case "filters.importRaw": | 231 case "filters.importRaw": |
207 var result = require("filterValidation").parseFilters(message.text); | 232 var result = require("filterValidation").parseFilters(message.text); |
208 var errors = []; | 233 var errors = []; |
209 for (var i = 0; i < result.errors.length; i++) | 234 for (var i = 0; i < result.errors.length; i++) |
210 { | 235 { |
211 var error = result.errors[i]; | 236 var error = result.errors[i]; |
212 if (error.type != "unexpected-filter-list-header") | 237 if (error.type != "unexpected-filter-list-header") |
213 errors.push(error.toString()); | 238 errors.push(error.toString()); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 subscription.title = message.title; | 341 subscription.title = message.title; |
317 subscription.homepage = message.homepage; | 342 subscription.homepage = message.homepage; |
318 FilterStorage.addSubscription(subscription); | 343 FilterStorage.addSubscription(subscription); |
319 if (!subscription.lastDownload) | 344 if (!subscription.lastDownload) |
320 Synchronizer.execute(subscription); | 345 Synchronizer.execute(subscription); |
321 } | 346 } |
322 break; | 347 break; |
323 } | 348 } |
324 }); | 349 }); |
325 })(this); | 350 })(this); |
OLD | NEW |