Index: lib/stats.js |
=================================================================== |
--- a/lib/stats.js |
+++ b/lib/stats.js |
@@ -24,6 +24,7 @@ |
let {FilterNotifier} = require("filterNotifier"); |
let badgeColor = "#646464"; |
+let statsPerTab = new TabMap(true); |
/** |
* Get statistics for specified tab |
@@ -36,8 +37,8 @@ |
if (!tab) |
return (key in Prefs.stats_total ? Prefs.stats_total[key] : 0); |
- let frameData = getFrameData(tab, 0); |
- return (frameData && key in frameData ? frameData[key] : 0); |
+ let tabStats = statsPerTab.get(tab); |
+ return tabStats ? tabStats.blocked : 0; |
}; |
FilterNotifier.addListener(function(action, item, newValue, oldValue, tab) |
@@ -56,21 +57,23 @@ |
Prefs.stats_total.blocked = 1; |
Prefs.stats_total = Prefs.stats_total; |
- let frameData = getFrameData(tab, 0); |
- if (frameData) |
+ let tabStats = statsPerTab.get(tab); |
+ if (!tabStats) |
{ |
- if ("blocked" in frameData) |
- frameData.blocked++; |
- else |
- frameData.blocked = 1; |
+ tabStats = {}; |
+ statsPerTab.set(tab, tabStats); |
} |
+ if ("blocked" in tabStats) |
+ tabStats.blocked++; |
+ else |
+ tabStats.blocked = 1; |
// Update number in icon |
if (Prefs.show_statsinicon) |
{ |
tab.browserAction.setBadge({ |
color: badgeColor, |
- number: frameData.blocked |
+ number: tabStats.blocked |
}); |
} |
} |
@@ -105,12 +108,12 @@ |
let badge = null; |
if (Prefs.show_statsinicon) |
{ |
- let frameData = getFrameData(tab, 0); |
- if (frameData && "blocked" in frameData) |
+ let tabStats = statsPerTab.get(tab); |
+ if (tabStats && "blocked" in tabStats) |
{ |
badge = { |
color: badgeColor, |
- number: frameData.blocked |
+ number: tabStats.blocked |
}; |
} |
} |