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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 const {FilterStorage} = require("filterStorage"); | 29 const {FilterStorage} = require("filterStorage"); |
30 const {FilterNotifier} = require("filterNotifier"); | 30 const {FilterNotifier} = require("filterNotifier"); |
31 const {defaultMatcher} = require("matcher"); | 31 const {defaultMatcher} = require("matcher"); |
32 const {ElemHideEmulation} = require("elemHideEmulation"); | 32 const {ElemHideEmulation} = require("elemHideEmulation"); |
33 const {Notification: NotificationStorage} = require("notification"); | 33 const {Notification: NotificationStorage} = require("notification"); |
34 | 34 |
35 const {Filter, BlockingFilter, RegExpFilter} = require("filterClasses"); | 35 const {Filter, BlockingFilter, RegExpFilter} = require("filterClasses"); |
36 const {Synchronizer} = require("synchronizer"); | 36 const {Synchronizer} = require("synchronizer"); |
37 | 37 |
38 const info = require("info"); | 38 const info = require("info"); |
39 const {Subscription, | 39 const { |
40 DownloadableSubscription, | 40 Subscription, |
41 SpecialSubscription} = require("subscriptionClasses"); | 41 DownloadableSubscription, |
| 42 SpecialSubscription |
| 43 } = require("subscriptionClasses"); |
42 | 44 |
43 // Some modules doesn't exist on Firefox. Moreover, | 45 // Some modules doesn't exist on Firefox. Moreover, |
44 // require() throws an exception on Firefox in that case. | 46 // require() throws an exception on Firefox in that case. |
45 // However, try/catch causes the whole function to to be | 47 // However, try/catch causes the whole function to to be |
46 // deoptimized on V8. So we wrap it into another function. | 48 // deoptimized on V8. So we wrap it into another function. |
47 function tryRequire(module) | 49 function tryRequire(module) |
48 { | 50 { |
49 try | 51 try |
50 { | 52 { |
51 return require(module); | 53 return require(module); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 }); | 192 }); |
191 | 193 |
192 port.on("app.listen", (message, sender) => | 194 port.on("app.listen", (message, sender) => |
193 { | 195 { |
194 getListenerFilters(sender.page).app = message.filter; | 196 getListenerFilters(sender.page).app = message.filter; |
195 }); | 197 }); |
196 | 198 |
197 port.on("app.open", (message, sender) => | 199 port.on("app.open", (message, sender) => |
198 { | 200 { |
199 if (message.what == "options") | 201 if (message.what == "options") |
200 ext.showOptions(); | 202 { |
| 203 ext.showOptions(() => |
| 204 { |
| 205 if (!message.action) |
| 206 return; |
| 207 |
| 208 sendMessage("app", message.action, ...message.args); |
| 209 }); |
| 210 } |
201 }); | 211 }); |
202 | 212 |
203 port.on("filters.add", (message, sender) => | 213 port.on("filters.add", (message, sender) => |
204 { | 214 { |
205 let result = require("filterValidation").parseFilter(message.text); | 215 let result = require("filterValidation").parseFilter(message.text); |
206 let errors = []; | 216 let errors = []; |
207 if (result.error) | 217 if (result.error) |
208 errors.push(result.error.toString()); | 218 errors.push(result.error.toString()); |
209 else if (result.filter) | 219 else if (result.filter) |
210 FilterStorage.addFilter(result.filter); | 220 FilterStorage.addFilter(result.filter); |
(...skipping 10 matching lines...) Expand all Loading... |
221 return filter instanceof BlockingFilter; | 231 return filter instanceof BlockingFilter; |
222 }); | 232 }); |
223 | 233 |
224 port.on("filters.get", (message, sender) => | 234 port.on("filters.get", (message, sender) => |
225 { | 235 { |
226 if (message.what == "elemhideemulation") | 236 if (message.what == "elemhideemulation") |
227 { | 237 { |
228 let filters = []; | 238 let filters = []; |
229 const {checkWhitelisted} = require("whitelisting"); | 239 const {checkWhitelisted} = require("whitelisting"); |
230 | 240 |
231 if (Prefs.enabled && !checkWhitelisted(sender.page, sender.frame, | 241 let isWhitelisted = checkWhitelisted(sender.page, sender.frame, |
232 RegExpFilter.typeMap.DOCUMENT | | 242 RegExpFilter.typeMap.DOCUMENT | RegExpFilter.typeMap.ELEMHIDE); |
233 RegExpFilter.typeMap.ELEMHIDE)) | 243 if (Prefs.enabled && !isWhitelisted) |
234 { | 244 { |
235 let {hostname} = sender.frame.url; | 245 let {hostname} = sender.frame.url; |
236 filters = ElemHideEmulation.getRulesForDomain(hostname); | 246 filters = ElemHideEmulation.getRulesForDomain(hostname); |
237 filters = filters.map((filter) => | 247 filters = filters.map((filter) => |
238 { | 248 { |
239 return { | 249 return { |
240 selector: filter.selector, | 250 selector: filter.selector, |
241 text: filter.text | 251 text: filter.text |
242 }; | 252 }; |
243 }); | 253 }); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 if (message.url) | 434 if (message.url) |
425 subscriptions = [Subscription.fromURL(message.url)]; | 435 subscriptions = [Subscription.fromURL(message.url)]; |
426 | 436 |
427 for (let subscription of subscriptions) | 437 for (let subscription of subscriptions) |
428 { | 438 { |
429 if (subscription instanceof DownloadableSubscription) | 439 if (subscription instanceof DownloadableSubscription) |
430 Synchronizer.execute(subscription, true); | 440 Synchronizer.execute(subscription, true); |
431 } | 441 } |
432 }); | 442 }); |
433 })(this); | 443 })(this); |
OLD | NEW |