LEFT | RIGHT |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 { | 61 { |
62 if ("blocked" in frameData) | 62 if ("blocked" in frameData) |
63 frameData.blocked++; | 63 frameData.blocked++; |
64 else | 64 else |
65 frameData.blocked = 1; | 65 frameData.blocked = 1; |
66 } | 66 } |
67 | 67 |
68 // Update number in icon | 68 // Update number in icon |
69 if (Prefs.show_statsinicon) | 69 if (Prefs.show_statsinicon) |
70 { | 70 { |
71 tab.browserAction.setBadgeBackgroundColor(badgeColor); | 71 tab.browserAction.setBadge({ |
72 tab.browserAction.setBadgeNumber(frameData.blocked); | 72 color: badgeColor, |
| 73 number: frameData.blocked |
| 74 }); |
73 } | 75 } |
74 } | 76 } |
75 }); | 77 }); |
76 | 78 |
77 /** | 79 /** |
78 * Execute function for each tab in any window | 80 * Execute function for each tab in any window |
79 * @param {Function} func function to be executed | 81 * @param {Function} func function to be executed |
80 */ | 82 */ |
81 function forEachTab(func) | 83 function forEachTab(func) |
82 { | 84 { |
83 ext.windows.getAll(function(windows) | 85 ext.windows.getAll(function(windows) |
84 { | 86 { |
85 for each (let window in windows) | 87 for each (let window in windows) |
86 { | 88 { |
87 window.getAllTabs(function(tabs) | 89 window.getAllTabs(function(tabs) |
88 { | 90 { |
89 for (let i = 0; i < tabs.length; i++) | 91 for (let i = 0; i < tabs.length; i++) |
90 func(tabs[i]); | 92 func(tabs[i]); |
91 }); | 93 }); |
92 } | 94 } |
93 }); | 95 }); |
94 } | 96 } |
95 | 97 |
96 Prefs.addListener(function(name) | 98 Prefs.addListener(function(name) |
97 { | 99 { |
98 if (name != "show_statsinicon") | 100 if (name != "show_statsinicon") |
99 return; | 101 return; |
100 | 102 |
101 forEachTab(function(tab) | 103 forEachTab(function(tab) |
102 { | 104 { |
103 let badgeNumber = null; | 105 let badge = null; |
104 if (Prefs.show_statsinicon) | 106 if (Prefs.show_statsinicon) |
105 { | 107 { |
106 let frameData = getFrameData(tab, 0); | 108 let frameData = getFrameData(tab, 0); |
107 if (frameData && "blocked" in frameData) | 109 if (frameData && "blocked" in frameData) |
108 { | 110 { |
109 badgeNumber = frameData.blocked; | 111 badge = { |
110 tab.browserAction.setBadgeBackgroundColor(badgeColor); | 112 color: badgeColor, |
| 113 number: frameData.blocked |
| 114 }; |
111 } | 115 } |
112 } | 116 } |
113 tab.browserAction.setBadgeNumber(badgeNumber); | 117 tab.browserAction.setBadge(badge); |
114 }); | 118 }); |
115 }); | 119 }); |
LEFT | RIGHT |