| 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 11 matching lines...) Expand all Loading... |
| 22 (function(global) | 22 (function(global) |
| 23 { | 23 { |
| 24 let ext = global.ext || require("ext_background"); | 24 let ext = global.ext || require("ext_background"); |
| 25 | 25 |
| 26 const {port} = require("messaging"); | 26 const {port} = require("messaging"); |
| 27 const {Prefs} = require("prefs"); | 27 const {Prefs} = require("prefs"); |
| 28 const {Utils} = require("utils"); | 28 const {Utils} = require("utils"); |
| 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"); | |
| 33 const {Notification: NotificationStorage} = require("notification"); | 32 const {Notification: NotificationStorage} = require("notification"); |
| 34 | 33 |
| 35 const {Filter, BlockingFilter, RegExpFilter} = require("filterClasses"); | 34 const {Filter, BlockingFilter, RegExpFilter} = require("filterClasses"); |
| 36 const {Synchronizer} = require("synchronizer"); | 35 const {Synchronizer} = require("synchronizer"); |
| 37 | 36 |
| 38 const info = require("info"); | 37 const info = require("info"); |
| 39 const { | 38 const { |
| 40 Subscription, | 39 Subscription, |
| 41 DownloadableSubscription, | 40 DownloadableSubscription, |
| 42 SpecialSubscription | 41 SpecialSubscription |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 { | 218 { |
| 220 let filter = defaultMatcher.matchesAny(message.url, | 219 let filter = defaultMatcher.matchesAny(message.url, |
| 221 RegExpFilter.typeMap[message.requestType], message.docDomain, | 220 RegExpFilter.typeMap[message.requestType], message.docDomain, |
| 222 message.thirdParty); | 221 message.thirdParty); |
| 223 | 222 |
| 224 return filter instanceof BlockingFilter; | 223 return filter instanceof BlockingFilter; |
| 225 }); | 224 }); |
| 226 | 225 |
| 227 port.on("filters.get", (message, sender) => | 226 port.on("filters.get", (message, sender) => |
| 228 { | 227 { |
| 229 if (message.what == "elemhideemulation") | |
| 230 { | |
| 231 let filters = []; | |
| 232 const {checkWhitelisted} = require("whitelisting"); | |
| 233 | |
| 234 let isWhitelisted = checkWhitelisted(sender.page, sender.frame, | |
| 235 RegExpFilter.typeMap.DOCUMENT | RegExpFilter.typeMap.ELEMHIDE); | |
| 236 if (Prefs.enabled && !isWhitelisted) | |
| 237 { | |
| 238 let {hostname} = sender.frame.url; | |
| 239 filters = ElemHideEmulation.getRulesForDomain(hostname); | |
| 240 filters = filters.map((filter) => | |
| 241 { | |
| 242 return { | |
| 243 selector: filter.selector, | |
| 244 text: filter.text | |
| 245 }; | |
| 246 }); | |
| 247 } | |
| 248 return filters; | |
| 249 } | |
| 250 | |
| 251 let subscription = Subscription.fromURL(message.subscriptionUrl); | 228 let subscription = Subscription.fromURL(message.subscriptionUrl); |
| 252 if (!subscription) | 229 if (!subscription) |
| 253 return []; | 230 return []; |
| 254 | 231 |
| 255 return subscription.filters.map(convertFilter); | 232 return subscription.filters.map(convertFilter); |
| 256 }); | 233 }); |
| 257 | 234 |
| 258 port.on("filters.importRaw", (message, sender) => | 235 port.on("filters.importRaw", (message, sender) => |
| 259 { | 236 { |
| 260 let result = require("filterValidation").parseFilters(message.text); | 237 let result = require("filterValidation").parseFilters(message.text); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 if (message.url) | 404 if (message.url) |
| 428 subscriptions = [Subscription.fromURL(message.url)]; | 405 subscriptions = [Subscription.fromURL(message.url)]; |
| 429 | 406 |
| 430 for (let subscription of subscriptions) | 407 for (let subscription of subscriptions) |
| 431 { | 408 { |
| 432 if (subscription instanceof DownloadableSubscription) | 409 if (subscription instanceof DownloadableSubscription) |
| 433 Synchronizer.execute(subscription, true); | 410 Synchronizer.execute(subscription, true); |
| 434 } | 411 } |
| 435 }); | 412 }); |
| 436 })(this); | 413 })(this); |
| OLD | NEW |