@@ -566,11 +566,14 @@ const matchBucket = function(url, hostname, bucket, start) {
566566/******************************************************************************/
567567
568568µb . toggleHostnameSwitch = function ( details ) {
569+ const newState = typeof details . state === 'boolean'
570+ ? details . state
571+ : sessionSwitches . evaluateZ ( details . name , details . hostname ) === false ;
569572 let changed = sessionSwitches . toggleZ (
570573 details . name ,
571574 details . hostname ,
572575 ! ! details . deep ,
573- details . state
576+ newState
574577 ) ;
575578 if ( changed === false ) { return ; }
576579
@@ -580,7 +583,7 @@ const matchBucket = function(url, hostname, bucket, start) {
580583 this . updateToolbarIcon ( details . tabId , 0b100 ) ;
581584 break ;
582585 case 'no-cosmetic-filtering' : {
583- const scriptlet = details . state ? 'cosmetic-off' : 'cosmetic-on' ;
586+ const scriptlet = newState ? 'cosmetic-off' : 'cosmetic-on' ;
584587 vAPI . tabs . executeScript ( details . tabId , {
585588 file : `/js/scriptlets/${ scriptlet } .js` ,
586589 allFrames : true ,
@@ -590,7 +593,7 @@ const matchBucket = function(url, hostname, bucket, start) {
590593 case 'no-large-media' :
591594 const pageStore = this . pageStoreFromTabId ( details . tabId ) ;
592595 if ( pageStore !== null ) {
593- pageStore . temporarilyAllowLargeMediaElements ( ! details . state ) ;
596+ pageStore . temporarilyAllowLargeMediaElements ( ! newState ) ;
594597 }
595598 break ;
596599 }
@@ -601,7 +604,7 @@ const matchBucket = function(url, hostname, bucket, start) {
601604 details . name ,
602605 details . hostname ,
603606 ! ! details . deep ,
604- details . state
607+ newState
605608 ) ;
606609 if ( changed ) {
607610 this . saveHostnameSwitches ( ) ;
0 commit comments