@@ -54,6 +54,11 @@ httpsEverywhere.toolbarButton = {
5454 // make sure icon is proper color during init
5555 tb . changeIcon ( ) ;
5656
57+ // make sure the checkbox for showing counter is properly set
58+ var showCounter = tb . shouldShowCounter ( ) ;
59+ var counterItem = document . getElementById ( 'https-everywhere-counter-item' ) ;
60+ counterItem . setAttribute ( 'checked' , showCounter ? 'true' : 'false' ) ;
61+
5762 // show ruleset counter when a tab is changed
5863 tb . updateRulesetsApplied ( ) ;
5964 gBrowser . tabContainer . addEventListener (
@@ -133,7 +138,8 @@ httpsEverywhere.toolbarButton = {
133138 updateRulesetsApplied : function ( ) {
134139 var toolbarbutton = document . getElementById ( 'https-everywhere-button' ) ;
135140 var enabled = HTTPSEverywhere . prefs . getBoolPref ( "globalEnabled" ) ;
136- if ( ! enabled ) {
141+ var showCounter = httpsEverywhere . toolbarButton . shouldShowCounter ( ) ;
142+ if ( ! enabled || ! showCounter ) {
137143 toolbarbutton . setAttribute ( 'rulesetsApplied' , 0 ) ;
138144 return ;
139145 }
@@ -171,11 +177,25 @@ httpsEverywhere.toolbarButton = {
171177 var tb = httpsEverywhere . toolbarButton ;
172178 var sp = Services . prefs ;
173179
174- var prefExists = ! sp . getPrefType ( tb . COUNTER_PREF ) == PREF_INVALID ;
180+ var prefExists = sp . getPrefType ( tb . COUNTER_PREF ) ;
175181
176182 // the default behavior is to show the rulesets applied counter.
177183 // if no preference exists (default) or its enabled, show the counter
178- return ! prefExists || sp . getBoolPref ( counterPref ) ;
184+ return ! prefExists || sp . getBoolPref ( tb . COUNTER_PREF ) ;
185+ } ,
186+
187+ /**
188+ * Toggles the user's preference for displaying the rulesets applied counter
189+ * and updates the UI.
190+ */
191+ toggleShowCounter : function ( ) {
192+ var tb = httpsEverywhere . toolbarButton ;
193+ var sp = Services . prefs ;
194+
195+ var showCounter = tb . shouldShowCounter ( ) ;
196+ sp . setBoolPref ( tb . COUNTER_PREF , ! showCounter ) ;
197+
198+ tb . updateRulesetsApplied ( ) ;
179199 }
180200
181201} ;
0 commit comments