Skip to content

Commit fcfeda2

Browse files
committed
Added option to disable rulesets applied counter.
1 parent c5baea4 commit fcfeda2

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

src/chrome/content/toolbar_button.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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
};

src/chrome/content/toolbar_button.xul

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
<menupopup id="https-everywhere-context" onpopupshowing="show_applicable_list(this)">
4343
<!-- entries will be written here by ApplicableList.populate_menu() -->
4444
<menuseparator />
45-
<menuitem type="checkbox" checked="true" label="Show Counter" oncommand="" />
45+
<menuitem type="checkbox" id="https-everywhere-counter-item" label="Show Counter"
46+
oncommand="httpsEverywhere.toolbarButton.toggleShowCounter()" />
4647
<menuseparator />
4748
<menuitem label="&https-everywhere.menu.observatory;" command="https-everywhere-menuitem-observatory" />
4849
<menuitem label="&https-everywhere.menu.about;" command="https-everywhere-menuitem-about" />

0 commit comments

Comments
 (0)