@@ -13,14 +13,27 @@ obsprefs = ssl_observatory.prefs;
1313const pref_prefix = "extensions.ssl_observatory." ;
1414
1515function observatory_prefs_init ( doc ) {
16+ // Is the Observatory on?
1617 var enabled = obsprefs . getBoolPref ( "extensions.https_everywhere._observatory_prefs.enabled" ) ;
1718 document . getElementById ( "use-observatory" ) . checked = enabled ;
1819 set_observatory_configurability ( enabled ) ;
19- // If the observatory is not yet on, and Tor is not available, the initial
20- // option is to turn it on /without/ Tor
21- if ( ( ! ssl_observatory . torbutton_installed ) && ! enabled ) {
22- var nonanon_radio = document . getElementById ( "ssl-obs-nonanon" ) ;
23- doc . getElementById ( "ssl-obs-how" ) . selectedItem = nonanon_radio ;
20+
21+ // More complicated: is it anonymised by Tor?
22+ var obs_how = doc . getElementById ( "ssl-obs-how" ) ;
23+ var anon_radio = document . getElementById ( "ssl-obs-anon" ) ;
24+ var nonanon_radio = document . getElementById ( "ssl-obs-nonanon" ) ;
25+ var anon = ! obsprefs . getBoolPref (
26+ "extensions.https_everywhere._observatory_prefs.use_custom_proxy" ) ;
27+
28+ // first set the radios to match the current settings variables
29+ obs_how . selectedItem = ( anon ) ? anon_radio : nonanon_radio ;
30+
31+ // But if the user hasn't turned the observatory on,
32+ // the default should be something maximally sensible
33+ var torbutton = ssl_observatory . torbutton_installed ;
34+ if ( ! enabled ) {
35+ set_obs_anon ( torbutton ) ;
36+ obs_how . selectedItem = ( torbutton ) ? anon_radio : nonanon_radio ;
2437 }
2538 //scale_title_logo();
2639}
@@ -32,9 +45,6 @@ function popup_done() {
3245 window . close ( ) ;
3346}
3447
35- function enable_observatory ( ) {
36- obsprefs . setBoolPref ( "extensions.https_everywhere._observatory_prefs.enabled" , true ) ;
37- }
3848
3949function scale_title_logo ( ) {
4050 // The image is naturally 500x207, but if it's shrunk we don't want it
@@ -85,6 +95,16 @@ function recursive_set(node, attrib, value) {
8595 recursive_set ( node . childNodes [ i ] , attrib , value )
8696}
8797
98+ // called from the popup
99+
100+ function set_obs_anon ( val ) {
101+ obsprefs . setBoolPref ( "extensions.https_everywhere._observatory_prefs.use_custom_proxy" , ! val ) ;
102+ }
103+ function enable_observatory ( ) {
104+ obsprefs . setBoolPref ( "extensions.https_everywhere._observatory_prefs.enabled" , true ) ;
105+ }
106+
107+ // called from within the prefs window, we have more work to do:
88108function toggle_enabled ( ) {
89109 var checkbox = document . getElementById ( "use-observatory" ) ;
90110 var use_obs = checkbox . checked ;
0 commit comments