| Left: | ||
| Right: |
| 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 |
| 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 /** | 18 /** |
| 19 * @fileOverview Stores Adblock Plus data to be attached to a window. | 19 * @fileOverview Stores Adblock Plus data to be attached to a window. |
| 20 */ | 20 */ |
| 21 | 21 |
| 22 let {Utils} = require("utils"); | 22 let {Utils} = require("utils"); |
| 23 let {BlockingFilter, WhitelistFilter, ElemHideBase, ElemHideFilter, ElemHideExce ption} = require("filterClasses"); | |
| 24 | 23 |
| 25 let nodeData = new WeakMap(); | 24 let nodeData = new WeakMap(); |
| 26 let windowStats = new WeakMap(); | 25 let windowStats = new WeakMap(); |
| 27 let windowSelection = new WeakMap(); | 26 let windowSelection = new WeakMap(); |
| 28 let requestNotifierMaxId = 0; | 27 let requestNotifierMaxId = 0; |
| 29 let requestEntryMaxId = 0; | 28 let requestEntryMaxId = 0; |
| 30 | 29 |
| 31 /** | 30 /** |
| 32 * Active RequestNotifier instances by their ID | 31 * Active RequestNotifier instances by their ID |
| 33 * @type Map | 32 * @type Map |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 windowStats.set(topWnd.document, { | 206 windowStats.set(topWnd.document, { |
| 208 items: 0, | 207 items: 0, |
| 209 hidden: 0, | 208 hidden: 0, |
| 210 blocked: 0, | 209 blocked: 0, |
| 211 whitelisted: 0, | 210 whitelisted: 0, |
| 212 filters: {} | 211 filters: {} |
| 213 }); | 212 }); |
| 214 } | 213 } |
| 215 | 214 |
| 216 let stats = windowStats.get(topWnd.document); | 215 let stats = windowStats.get(topWnd.document); |
| 217 if (!filter || !(filter instanceof ElemHideBase)) | 216 let filterType = (filter ? filter.type : null); |
| 217 if (filterType != "elemhide" && filterType != "elemhideexception" && filterTyp e != "cssproperty") | |
|
Thomas Greiner
2015/11/03 11:32:40
Just a suggestion: What about introducing an `isEx
Wladimir Palant
2015/11/03 12:23:24
I think that would complicate things more than it
| |
| 218 stats.items++; | 218 stats.items++; |
| 219 if (filter) | 219 if (filter) |
| 220 { | 220 { |
| 221 if (filter instanceof BlockingFilter) | 221 if (filterType == "blocking") |
| 222 stats.blocked++; | 222 stats.blocked++; |
| 223 else if (filter instanceof WhitelistFilter || filter instanceof ElemHideExce ption) | 223 else if (filterType == "whitelist" || filterType == "elemhideexception") |
| 224 stats.whitelisted++; | 224 stats.whitelisted++; |
| 225 else if (filter instanceof ElemHideFilter) | 225 else if (filterType == "elemhide" || filterType == "cssproperty") |
| 226 stats.hidden++; | 226 stats.hidden++; |
| 227 | 227 |
| 228 if (filter.text in stats.filters) | 228 if (filter.text in stats.filters) |
| 229 stats.filters[filter.text]++; | 229 stats.filters[filter.text]++; |
| 230 else | 230 else |
| 231 stats.filters[filter.text] = 1; | 231 stats.filters[filter.text] = 1; |
| 232 } | 232 } |
| 233 | 233 |
| 234 // Notify listeners | 234 // Notify listeners |
| 235 for (let notifier of notifiers.values()) | 235 for (let notifier of notifiers.values()) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 node = node.parentNode; | 287 node = node.parentNode; |
| 288 } | 288 } |
| 289 else | 289 else |
| 290 { | 290 { |
| 291 node = null; | 291 node = null; |
| 292 } | 292 } |
| 293 } | 293 } |
| 294 | 294 |
| 295 return null; | 295 return null; |
| 296 }; | 296 }; |
| OLD | NEW |