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 stats */ | 18 /** @module stats */ |
19 | 19 |
20 "use strict"; | 20 "use strict"; |
21 | 21 |
22 const {Prefs} = require("./prefs"); | 22 const {Prefs} = require("./prefs"); |
23 const {BlockingFilter} = require("../adblockpluscore/lib/filterClasses"); | 23 const {BlockingFilter} = require("../adblockpluscore/lib/filterClasses"); |
24 const {FilterNotifier} = require("../adblockpluscore/lib/filterNotifier"); | 24 const {filterNotifier} = require("../adblockpluscore/lib/filterNotifier"); |
25 const {port} = require("./messaging"); | 25 const {port} = require("./messaging"); |
26 | 26 |
27 const badgeColor = "#646464"; | 27 const badgeColor = "#646464"; |
28 let blockedPerPage = new ext.PageMap(); | 28 let blockedPerPage = new ext.PageMap(); |
29 | 29 |
30 let getBlockedPerPage = | 30 let getBlockedPerPage = |
31 /** | 31 /** |
32 * Gets the number of requests blocked on the given page. | 32 * Gets the number of requests blocked on the given page. |
33 * | 33 * |
34 * @param {Page} page | 34 * @param {Page} page |
(...skipping 19 matching lines...) Expand all Loading... |
54 { | 54 { |
55 if (details.frameId == 0) | 55 if (details.frameId == 0) |
56 { | 56 { |
57 let page = new ext.Page({id: details.tabId}); | 57 let page = new ext.Page({id: details.tabId}); |
58 let blocked = blockedPerPage.get(page); | 58 let blocked = blockedPerPage.get(page); |
59 | 59 |
60 updateBadge(page, blocked); | 60 updateBadge(page, blocked); |
61 } | 61 } |
62 }); | 62 }); |
63 | 63 |
64 FilterNotifier.on("filter.hitCount", (filter, newValue, oldValue, tabIds) => | 64 filterNotifier.on("filter.hitCount", (filter, newValue, oldValue, tabIds) => |
65 { | 65 { |
66 if (!(filter instanceof BlockingFilter)) | 66 if (!(filter instanceof BlockingFilter)) |
67 return; | 67 return; |
68 | 68 |
69 for (let tabId of tabIds) | 69 for (let tabId of tabIds) |
70 { | 70 { |
71 let page = new ext.Page({id: tabId}); | 71 let page = new ext.Page({id: tabId}); |
72 let blocked = blockedPerPage.get(page) || 0; | 72 let blocked = blockedPerPage.get(page) || 0; |
73 | 73 |
74 blockedPerPage.set(page, ++blocked); | 74 blockedPerPage.set(page, ++blocked); |
(...skipping 14 matching lines...) Expand all Loading... |
89 if (Prefs.show_statsinicon) | 89 if (Prefs.show_statsinicon) |
90 updateBadge(page, blockedPerPage.get(page)); | 90 updateBadge(page, blockedPerPage.get(page)); |
91 else | 91 else |
92 page.browserAction.setBadge(null); | 92 page.browserAction.setBadge(null); |
93 } | 93 } |
94 }); | 94 }); |
95 }); | 95 }); |
96 | 96 |
97 port.on("stats.getBlockedPerPage", | 97 port.on("stats.getBlockedPerPage", |
98 message => getBlockedPerPage(new ext.Page(message.tab))); | 98 message => getBlockedPerPage(new ext.Page(message.tab))); |
OLD | NEW |