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 |
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 "use strict"; | 18 "use strict"; |
19 | 19 |
20 const {RegExpFilter, | 20 const {RegExpFilter, |
21 WhitelistFilter, | 21 WhitelistFilter, |
22 ElemHideFilter} = require("../adblockpluscore/lib/filterClasses"); | 22 ElemHideFilter} = require("../adblockpluscore/lib/filterClasses"); |
23 const {SpecialSubscription} = | 23 const {SpecialSubscription} = |
24 require("../adblockpluscore/lib/subscriptionClasses"); | 24 require("../adblockpluscore/lib/subscriptionClasses"); |
25 const {FilterStorage} = require("../adblockpluscore/lib/filterStorage"); | 25 const {FilterStorage} = require("../adblockpluscore/lib/filterStorage"); |
26 const {defaultMatcher} = require("../adblockpluscore/lib/matcher"); | 26 const {defaultMatcher} = require("../adblockpluscore/lib/matcher"); |
27 const {FilterNotifier} = require("../adblockpluscore/lib/filterNotifier"); | 27 const {filterNotifier} = require("../adblockpluscore/lib/filterNotifier"); |
28 const {extractHostFromFrame} = require("./url"); | 28 const {extractHostFromFrame} = require("./url"); |
29 const {port} = require("./messaging"); | 29 const {port} = require("./messaging"); |
30 const {HitLogger, nonRequestTypes} = require("./hitLogger"); | 30 const {HitLogger, nonRequestTypes} = require("./hitLogger"); |
31 | 31 |
32 let panels = new Map(); | 32 let panels = new Map(); |
33 | 33 |
34 function isActivePanel(panel) | 34 function isActivePanel(panel) |
35 { | 35 { |
36 return panel && !panel.reload && !panel.reloading; | 36 return panel && !panel.reload && !panel.reloading; |
37 } | 37 } |
38 | 38 |
39 function getActivePanel(tabId) | 39 function getActivePanel(tabId) |
40 { | 40 { |
41 let panel = panels.get(tabId); | 41 let panel = panels.get(tabId); |
42 if (isActivePanel(panel)) | 42 if (isActivePanel(panel)) |
43 return panel; | 43 return panel; |
44 return null; | 44 return null; |
45 } | 45 } |
46 | 46 |
47 function getFilterInfo(filter) | 47 function getFilterInfo(filter) |
48 { | 48 { |
49 if (!filter) | 49 if (!filter) |
50 return null; | 50 return null; |
51 | 51 |
52 let userDefined = false; | 52 let userDefined = false; |
53 let subscriptionTitle = null; | 53 let subscriptionTitle = null; |
54 | 54 |
55 for (let subscription of filter.subscriptions) | 55 for (let subscription of filter.subscriptions()) |
56 { | 56 { |
57 if (!subscription.disabled) | 57 if (!subscription.disabled) |
58 { | 58 { |
59 if (subscription instanceof SpecialSubscription) | 59 if (subscription instanceof SpecialSubscription) |
60 userDefined = true; | 60 userDefined = true; |
61 else | 61 else |
62 subscriptionTitle = subscription.title; | 62 subscriptionTitle = subscription.title; |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 { | 247 { |
248 urls: ["http://*/*", "https://*/*"], | 248 urls: ["http://*/*", "https://*/*"], |
249 types: ["main_frame"], | 249 types: ["main_frame"], |
250 tabId: inspectedTabId | 250 tabId: inspectedTabId |
251 } | 251 } |
252 ); | 252 ); |
253 | 253 |
254 if (panels.size == 0) | 254 if (panels.size == 0) |
255 { | 255 { |
256 ext.pages.onLoading.addListener(onLoading); | 256 ext.pages.onLoading.addListener(onLoading); |
257 FilterNotifier.on("filter.added", onFilterAdded); | 257 filterNotifier.on("filter.added", onFilterAdded); |
258 FilterNotifier.on("filter.removed", onFilterRemoved); | 258 filterNotifier.on("filter.removed", onFilterRemoved); |
259 FilterNotifier.on("subscription.added", onSubscriptionAdded); | 259 filterNotifier.on("subscription.added", onSubscriptionAdded); |
260 } | 260 } |
261 | 261 |
262 newPort.onDisconnect.addListener(() => | 262 newPort.onDisconnect.addListener(() => |
263 { | 263 { |
264 HitLogger.removeListener(inspectedTabId, hitListener); | 264 HitLogger.removeListener(inspectedTabId, hitListener); |
265 panels.delete(inspectedTabId); | 265 panels.delete(inspectedTabId); |
266 browser.webRequest.onBeforeRequest.removeListener(localOnBeforeRequest); | 266 browser.webRequest.onBeforeRequest.removeListener(localOnBeforeRequest); |
267 | 267 |
268 if (panels.size == 0) | 268 if (panels.size == 0) |
269 { | 269 { |
270 ext.pages.onLoading.removeListener(onLoading); | 270 ext.pages.onLoading.removeListener(onLoading); |
271 FilterNotifier.off("filter.added", onFilterAdded); | 271 filterNotifier.off("filter.added", onFilterAdded); |
272 FilterNotifier.off("filter.removed", onFilterRemoved); | 272 filterNotifier.off("filter.removed", onFilterRemoved); |
273 FilterNotifier.off("subscription.added", onSubscriptionAdded); | 273 filterNotifier.off("subscription.added", onSubscriptionAdded); |
274 } | 274 } |
275 }); | 275 }); |
276 | 276 |
277 HitLogger.addListener(inspectedTabId, hitListener); | 277 HitLogger.addListener(inspectedTabId, hitListener); |
278 panels.set(inspectedTabId, panel); | 278 panels.set(inspectedTabId, panel); |
279 }); | 279 }); |
OLD | NEW |