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 /** @module hitLogger */ | 18 /** @module hitLogger */ |
19 | 19 |
20 "use strict"; | 20 "use strict"; |
21 | 21 |
22 const {extractHostFromFrame} = require("./url"); | 22 const {extractHostFromFrame} = require("./url"); |
23 const {EventEmitter} = require("../adblockpluscore/lib/events"); | 23 const {EventEmitter} = require("../adblockpluscore/lib/events"); |
24 const {FilterStorage} = require("../adblockpluscore/lib/filterStorage"); | 24 const {filterStorage} = require("../adblockpluscore/lib/filterStorage"); |
25 const {port} = require("./messaging"); | 25 const {port} = require("./messaging"); |
26 const {RegExpFilter, | 26 const {RegExpFilter, |
27 ElemHideFilter} = require("../adblockpluscore/lib/filterClasses"); | 27 ElemHideFilter} = require("../adblockpluscore/lib/filterClasses"); |
28 | 28 |
29 const nonRequestTypes = exports.nonRequestTypes = [ | 29 const nonRequestTypes = exports.nonRequestTypes = [ |
30 "DOCUMENT", "ELEMHIDE", "SNIPPET", "GENERICBLOCK", "GENERICHIDE", "CSP" | 30 "DOCUMENT", "ELEMHIDE", "SNIPPET", "GENERICBLOCK", "GENERICHIDE", "CSP" |
31 ]; | 31 ]; |
32 | 32 |
33 let eventEmitter = new EventEmitter(); | 33 let eventEmitter = new EventEmitter(); |
34 | 34 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 * | 102 * |
103 * @param {number} tabId The ID of the tab, the elements were hidden in | 103 * @param {number} tabId The ID of the tab, the elements were hidden in |
104 * @param {string[]} selectors The selectors of applied ElemHideFilters | 104 * @param {string[]} selectors The selectors of applied ElemHideFilters |
105 * @param {string[]} filters The text of applied ElemHideEmulationFilters | 105 * @param {string[]} filters The text of applied ElemHideEmulationFilters |
106 * @param {string} docDomain The hostname of the document | 106 * @param {string} docDomain The hostname of the document |
107 */ | 107 */ |
108 function logHiddenElements(tabId, selectors, filters, docDomain) | 108 function logHiddenElements(tabId, selectors, filters, docDomain) |
109 { | 109 { |
110 if (HitLogger.hasListener(tabId)) | 110 if (HitLogger.hasListener(tabId)) |
111 { | 111 { |
112 for (let subscription of FilterStorage.subscriptions) | 112 for (let subscription of filterStorage.subscriptions()) |
113 { | 113 { |
114 if (subscription.disabled) | 114 if (subscription.disabled) |
115 continue; | 115 continue; |
116 | 116 |
117 for (let filter of subscription.filters) | 117 for (let filter of subscription.filters) |
118 { | 118 { |
119 // We only know the exact filter in case of element hiding emulation. | 119 // We only know the exact filter in case of element hiding emulation. |
120 // For regular element hiding filters, the content script only knows | 120 // For regular element hiding filters, the content script only knows |
121 // the selector, so we have to find a filter that has an identical | 121 // the selector, so we have to find a filter that has an identical |
122 // selector and is active on the domain the match was reported from. | 122 // selector and is active on the domain the match was reported from. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 } | 154 } |
155 }; | 155 }; |
156 | 156 |
157 port.on("hitLogger.traceElemHide", (message, sender) => | 157 port.on("hitLogger.traceElemHide", (message, sender) => |
158 { | 158 { |
159 logHiddenElements( | 159 logHiddenElements( |
160 sender.page.id, message.selectors, message.filters, | 160 sender.page.id, message.selectors, message.filters, |
161 extractHostFromFrame(sender.frame) | 161 extractHostFromFrame(sender.frame) |
162 ); | 162 ); |
163 }); | 163 }); |
OLD | NEW |