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 |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 }; | 273 }; |
274 | 274 |
275 /** | 275 /** |
276 * Attaches request data to a DOM node. | 276 * Attaches request data to a DOM node. |
277 * @param {Node} node node to attach data to | 277 * @param {Node} node node to attach data to |
278 * @param {Window} topWnd top-level window the node belongs to | 278 * @param {Window} topWnd top-level window the node belongs to |
279 * @param {String} contentType request type, e.g. "IMAGE" | 279 * @param {String} contentType request type, e.g. "IMAGE" |
280 * @param {String} docDomain domain of the document that initiated the request | 280 * @param {String} docDomain domain of the document that initiated the request |
281 * @param {Boolean} thirdParty will be true if a third-party server has been re
quested | 281 * @param {Boolean} thirdParty will be true if a third-party server has been re
quested |
282 * @param {String} location the address that has been requested | 282 * @param {String} location the address that has been requested |
283 * @param {Filter} filter filter applied to the request or null if none | 283 * @param {String} filter filter applied to the request or null if none |
| 284 * @param {String} filterType type of filter applied to the request |
284 */ | 285 */ |
285 RequestNotifier.addNodeData = function(node, topWnd, contentType, docDomain, thi
rdParty, location, filter) | 286 RequestNotifier.addNodeData = function(node, topWnd, {contentType, docDomain, th
irdParty, location, filter, filterType}) |
286 { | 287 { |
287 let entry = { | 288 let entry = { |
288 id: ++requestEntryMaxId, | 289 id: ++requestEntryMaxId, |
289 type: contentType, | 290 type: contentType, |
290 docDomain, thirdParty, location, filter | 291 docDomain, thirdParty, location, filter |
291 }; | 292 }; |
292 | 293 |
293 let existingData = nodeData.get(node); | 294 let existingData = nodeData.get(node); |
294 if (typeof existingData == "undefined") | 295 if (typeof existingData == "undefined") |
295 { | 296 { |
(...skipping 10 matching lines...) Expand all Loading... |
306 windowStats.set(topWnd.document, { | 307 windowStats.set(topWnd.document, { |
307 items: 0, | 308 items: 0, |
308 hidden: 0, | 309 hidden: 0, |
309 blocked: 0, | 310 blocked: 0, |
310 whitelisted: 0, | 311 whitelisted: 0, |
311 filters: {} | 312 filters: {} |
312 }); | 313 }); |
313 } | 314 } |
314 | 315 |
315 let stats = windowStats.get(topWnd.document); | 316 let stats = windowStats.get(topWnd.document); |
316 let filterType = (filter ? filter.type : null); | |
317 if (filterType != "elemhide" && filterType != "elemhideexception" && filterTyp
e != "cssproperty") | 317 if (filterType != "elemhide" && filterType != "elemhideexception" && filterTyp
e != "cssproperty") |
318 stats.items++; | 318 stats.items++; |
319 if (filter) | 319 if (filter) |
320 { | 320 { |
321 if (filterType == "blocking") | 321 if (filterType == "blocking") |
322 stats.blocked++; | 322 stats.blocked++; |
323 else if (filterType == "whitelist" || filterType == "elemhideexception") | 323 else if (filterType == "whitelist" || filterType == "elemhideexception") |
324 stats.whitelisted++; | 324 stats.whitelisted++; |
325 else if (filterType == "elemhide" || filterType == "cssproperty") | 325 else if (filterType == "elemhide" || filterType == "cssproperty") |
326 stats.hidden++; | 326 stats.hidden++; |
327 | 327 |
328 if (filter.text in stats.filters) | 328 if (filter in stats.filters) |
329 stats.filters[filter.text]++; | 329 stats.filters[filter]++; |
330 else | 330 else |
331 stats.filters[filter.text] = 1; | 331 stats.filters[filter] = 1; |
332 } | 332 } |
333 | 333 |
334 // Notify listeners | 334 // Notify listeners |
335 for (let notifier of notifiers.values()) | 335 for (let notifier of notifiers.values()) |
336 if (!notifier.window || notifier.window == topWnd) | 336 if (!notifier.window || notifier.window == topWnd) |
337 notifier.notifyListener(node, entry); | 337 notifier.notifyListener(node, entry); |
338 } | 338 } |
OLD | NEW |