@@ -566,11 +566,14 @@ const matchBucket = function(url, hostname, bucket, start) {
566
566
/******************************************************************************/
567
567
568
568
µb . toggleHostnameSwitch = function ( details ) {
569
+ const newState = typeof details . state === 'boolean'
570
+ ? details . state
571
+ : sessionSwitches . evaluateZ ( details . name , details . hostname ) === false ;
569
572
let changed = sessionSwitches . toggleZ (
570
573
details . name ,
571
574
details . hostname ,
572
575
! ! details . deep ,
573
- details . state
576
+ newState
574
577
) ;
575
578
if ( changed === false ) { return ; }
576
579
@@ -580,7 +583,7 @@ const matchBucket = function(url, hostname, bucket, start) {
580
583
this . updateToolbarIcon ( details . tabId , 0b100 ) ;
581
584
break ;
582
585
case 'no-cosmetic-filtering' : {
583
- const scriptlet = details . state ? 'cosmetic-off' : 'cosmetic-on' ;
586
+ const scriptlet = newState ? 'cosmetic-off' : 'cosmetic-on' ;
584
587
vAPI . tabs . executeScript ( details . tabId , {
585
588
file : `/js/scriptlets/${ scriptlet } .js` ,
586
589
allFrames : true ,
@@ -590,7 +593,7 @@ const matchBucket = function(url, hostname, bucket, start) {
590
593
case 'no-large-media' :
591
594
const pageStore = this . pageStoreFromTabId ( details . tabId ) ;
592
595
if ( pageStore !== null ) {
593
- pageStore . temporarilyAllowLargeMediaElements ( ! details . state ) ;
596
+ pageStore . temporarilyAllowLargeMediaElements ( ! newState ) ;
594
597
}
595
598
break ;
596
599
}
@@ -601,7 +604,7 @@ const matchBucket = function(url, hostname, bucket, start) {
601
604
details . name ,
602
605
details . hostname ,
603
606
! ! details . deep ,
604
- details . state
607
+ newState
605
608
) ;
606
609
if ( changed ) {
607
610
this . saveHostnameSwitches ( ) ;
0 commit comments