@@ -65,15 +65,21 @@ httpsEverywhere.toolbarButton = {
6565 // make sure the checkbox for showing counter is properly set
6666 var showCounter = tb . shouldShowCounter ( ) ;
6767 var counterItem = document . getElementById ( 'https-everywhere-counter-item' ) ;
68- counterItem . setAttribute ( 'checked' , showCounter ? 'true' : 'false' ) ;
68+ if ( counterItem ) {
69+ counterItem . setAttribute ( 'checked' , showCounter ? 'true' : 'false' ) ;
70+ }
6971
7072 // make sure UI for HTTP Nowhere mode is properly set
7173 var httpNowhereItem = document . getElementById ( 'http-nowhere-item' ) ;
7274 var showHttpNowhere = tb . shouldShowHttpNowhere ( ) ;
7375 var toolbarbutton = document . getElementById ( 'https-everywhere-button' ) ;
74- httpNowhereItem . setAttribute ( 'checked' , showHttpNowhere ? 'true' : 'false' ) ;
75- toolbarbutton . setAttribute ( 'http_nowhere' ,
76- showHttpNowhere ? 'true' : 'false' ) ;
76+ if ( httpNowhereItem ) {
77+ httpNowhereItem . setAttribute ( 'checked' , showHttpNowhere ? 'true' : 'false' ) ;
78+ }
79+ if ( toolbarbutton ) {
80+ toolbarbutton . setAttribute ( 'http_nowhere' ,
81+ showHttpNowhere ? 'true' : 'false' ) ;
82+ }
7783
7884 // make sure UI is set depending on whether HTTPS-E is enabled
7985 toggleEnabledUI ( ) ;
@@ -163,6 +169,10 @@ httpsEverywhere.toolbarButton = {
163169 */
164170 updateRulesetsApplied : function ( ) {
165171 var toolbarbutton = document . getElementById ( 'https-everywhere-button' ) ;
172+ if ( ! toolbarbutton ) {
173+ return ;
174+ }
175+
166176 var enabled = HTTPSEverywhere . prefs . getBoolPref ( "globalEnabled" ) ;
167177 var showCounter = httpsEverywhere . toolbarButton . shouldShowCounter ( ) ;
168178 if ( ! enabled || ! showCounter ) {
@@ -363,7 +373,9 @@ function toggleEnabledUI() {
363373
364374 // Change icon depending on enabled state
365375 var toolbarbutton = document . getElementById ( 'https-everywhere-button' ) ;
366- toolbarbutton . setAttribute ( 'status' , enabled ? 'enabled' : 'disabled' ) ;
376+ if ( toolbarbutton ) {
377+ toolbarbutton . setAttribute ( 'status' , enabled ? 'enabled' : 'disabled' ) ;
378+ }
367379}
368380
369381function open_in_tab ( url ) {
0 commit comments