@@ -7,17 +7,16 @@ serial_number = 0
77function ApplicableList ( logger , doc , domWin ) {
88 this . domWin = domWin ;
99 this . home = doc . baseURIObject . spec ; // what doc we're housekeeping for
10+ this . doc = doc ;
1011 this . log = logger ;
1112 this . active = { } ;
13+ this . breaking = { } ; // rulesets with redirection loops
1214 this . inactive = { } ;
1315 this . moot = { } ; // rulesets that might be applicable but uris are already https
14- this . all = { } ; // active + inactive + moot
16+ this . all = { } ; // active + breaking + inactive + moot
1517 serial_number += 1 ;
1618 this . serial = serial_number ;
1719 this . log ( DBUG , "Alist serial #" + this . serial + " for " + this . home ) ;
18- // The base URI of the dom tends to be loaded from some /other/
19- // ApplicableList, so pretend we're loading it from here.
20- HTTPSEverywhere . instance . https_rules . rewrittenURI ( this , doc . baseURIObject ) ;
2120} ;
2221
2322ApplicableList . prototype = {
@@ -29,6 +28,13 @@ ApplicableList.prototype = {
2928 this . all [ ruleset . name ] = ruleset ;
3029 } ,
3130
31+ breaking_rule : function ( ruleset ) {
32+ this . log ( WARN , "breaking rule " + ruleset . name + " in " + this . home + " -> " +
33+ this . domWin . document . baseURIObject . spec + " serial " + this . serial ) ;
34+ this . breaking [ ruleset . name ] = ruleset ;
35+ this . all [ ruleset . name ] = ruleset ;
36+ } ,
37+
3238 inactive_rule : function ( ruleset ) {
3339
3440 this . log ( INFO , "inactive rule " + ruleset . name + " in " + this . home + " -> " +
@@ -50,6 +56,13 @@ ApplicableList.prototype = {
5056 } ,
5157
5258 populate_menu : function ( document ) {
59+
60+ // The base URI of the dom tends to be loaded from some /other/
61+ // ApplicableList, so pretend we're loading it from here.
62+ this . log ( WARN , "BASE uri is" , this . doc . baseURIObject . spec ) ;
63+ this . log ( WARN , "home is" , this . home ) ;
64+ HTTPSEverywhere . instance . https_rules . rewrittenURI ( this , this . doc . baseURIObject ) ;
65+ this . show_applicable ( ) ;
5366 this . log ( DBUG , "populating using alist #" + this . serial ) ;
5467 this . document = document ;
5568
@@ -62,12 +75,13 @@ ApplicableList.prototype = {
6275 }
6376
6477 // add the label at the top
65- var rules_count = 0 ;
66- for ( x in this . active ) rules_count ++ ;
67- for ( x in this . inactive ) rules_count ++ ;
68- for ( x in this . moot ) rules_count ++ ;
78+ var any_rules = false
79+ for ( var x in this . all ) {
80+ any_rules = true ; // how did JavaScript get this ugly?
81+ break ;
82+ }
6983 var label = document . createElement ( 'menuitem' ) ;
70- if ( rules_count > 0 ) {
84+ if ( any_rules ) {
7185 label . setAttribute ( 'label' , 'Enable / Disable Rules' ) ;
7286 } else {
7387 label . setAttribute ( 'label' , '(No Rules for This Page)' ) ;
@@ -89,6 +103,8 @@ ApplicableList.prototype = {
89103 }
90104
91105 // add all applicable commands
106+ for ( var x in this . breaking )
107+ this . add_command ( this . breaking [ x ] ) ;
92108 for ( var x in this . active )
93109 this . add_command ( this . active [ x ] ) ;
94110 for ( var x in this . moot )
@@ -97,13 +113,17 @@ ApplicableList.prototype = {
97113 this . add_command ( this . inactive [ x ] ) ;
98114
99115 // add all the menu items
100- for ( var x in this . active )
101- this . add_menuitem ( this . active [ x ] , 'active' ) ;
116+ for ( var x in this . breaking )
117+ this . add_menuitem ( this . breaking [ x ] , 'breaking' ) ;
118+ // break once break everywhere
119+ for ( var x in this . active )
120+ if ( ! ( x in this . breaking ) )
121+ this . add_menuitem ( this . active [ x ] , 'active' ) ;
102122 // rules that are active for some uris are not really moot
103- for ( var x in this . moot )
104- if ( ! ( x in this . active ) )
123+ for ( var x in this . moot )
124+ if ( ! ( x in this . active ) )
105125 this . add_menuitem ( this . moot [ x ] , 'moot' ) ;
106- for ( var x in this . inactive )
126+ for ( var x in this . inactive )
107127 this . add_menuitem ( this . inactive [ x ] , 'inactive' ) ;
108128
109129 // add other menu items
@@ -140,7 +160,9 @@ ApplicableList.prototype = {
140160 this . commandset . appendChild ( command ) ;
141161 } ,
142162
143- // add a menu item for a rule -- type is "active", "inactive", or "moot"
163+ // add a menu item for a rule -- type is "active", "inactive", "moot",
164+ // or "breaking"
165+
144166 add_menuitem : function ( rule , type ) {
145167 // create the menuitem
146168 var item = this . document . createElement ( 'menuitem' ) ;
@@ -150,9 +172,10 @@ ApplicableList.prototype = {
150172 // set the icon
151173 var image = this . document . createElement ( 'image' ) ;
152174 var image_src ;
153- if ( type == 'active' ) image_src = 'tick.png' ;
154- else if ( type == 'inactive' ) image_src = 'cross.png' ;
155- else if ( type == 'moot' ) image_src = 'tick-moot.png' ;
175+ if ( type == 'active' ) image_src = 'tick.png' ;
176+ else if ( type == 'inactive' ) image_src = 'cross.png' ;
177+ else if ( type == 'moot' ) image_src = 'tick-moot.png' ;
178+ else if ( type == 'breaking' ) image_src = 'tick-red.png' ;
156179 image . setAttribute ( 'src' , 'chrome://https-everywhere/skin/' + image_src ) ;
157180
158181 // set the label
@@ -173,6 +196,9 @@ ApplicableList.prototype = {
173196 this . log ( WARN , "Applicable list number " + this . serial ) ;
174197 for ( var x in this . active )
175198 this . log ( WARN , "Active: " + this . active [ x ] . name ) ;
199+
200+ for ( var x in this . breaking )
201+ this . log ( WARN , "Breaking: " + this . breaking [ x ] . name ) ;
176202
177203 for ( x in this . inactive )
178204 this . log ( WARN , "Inactive: " + this . inactive [ x ] . name ) ;
0 commit comments