@@ -594,6 +594,8 @@ export class Extension implements ExtensionState {
594594 const mode = this . autoState === 'scheme-dark' ? 1 : 0 ;
595595 theme = { ...theme , mode} ;
596596 }
597+ const isIFrame = frameURL != null ;
598+ const detectDarkTheme = ! isIFrame && this . user . settings . detectDarkTheme ;
597599
598600 logInfo ( `Creating CSS for url: ${ url } ` ) ;
599601 logInfo ( `Custom theme ${ custom ? 'was found' : 'was not found' } , Preset theme ${ preset ? 'was found' : 'was not found' }
@@ -602,14 +604,20 @@ export class Extension implements ExtensionState {
602604 case ThemeEngines . cssFilter : {
603605 return {
604606 type : MessageType . BG_ADD_CSS_FILTER ,
605- data : createCSSFilterStylesheet ( theme , url , frameURL , this . config . INVERSION_FIXES_RAW , this . config . INVERSION_FIXES_INDEX ) ,
607+ data : {
608+ css : createCSSFilterStylesheet ( theme , url , frameURL , this . config . INVERSION_FIXES_RAW , this . config . INVERSION_FIXES_INDEX ) ,
609+ detectDarkTheme,
610+ } ,
606611 } ;
607612 }
608613 case ThemeEngines . svgFilter : {
609614 if ( isFirefox ) {
610615 return {
611616 type : MessageType . BG_ADD_CSS_FILTER ,
612- data : createSVGFilterStylesheet ( theme , url , frameURL , this . config . INVERSION_FIXES_RAW , this . config . INVERSION_FIXES_INDEX ) ,
617+ data : {
618+ css : createSVGFilterStylesheet ( theme , url , frameURL , this . config . INVERSION_FIXES_RAW , this . config . INVERSION_FIXES_INDEX ) ,
619+ detectDarkTheme,
620+ } ,
613621 } ;
614622 }
615623 return {
@@ -618,25 +626,31 @@ export class Extension implements ExtensionState {
618626 css : createSVGFilterStylesheet ( theme , url , frameURL , this . config . INVERSION_FIXES_RAW , this . config . INVERSION_FIXES_INDEX ) ,
619627 svgMatrix : getSVGFilterMatrixValue ( theme ) ,
620628 svgReverseMatrix : getSVGReverseFilterMatrixValue ( ) ,
629+ detectDarkTheme,
621630 } ,
622631 } ;
623632 }
624633 case ThemeEngines . staticTheme : {
625634 return {
626635 type : MessageType . BG_ADD_STATIC_THEME ,
627- data : theme . stylesheet && theme . stylesheet . trim ( ) ?
628- theme . stylesheet :
629- createStaticStylesheet ( theme , url , frameURL , this . config . STATIC_THEMES_RAW , this . config . STATIC_THEMES_INDEX ) ,
636+ data : {
637+ css : theme . stylesheet && theme . stylesheet . trim ( ) ?
638+ theme . stylesheet :
639+ createStaticStylesheet ( theme , url , frameURL , this . config . STATIC_THEMES_RAW , this . config . STATIC_THEMES_INDEX ) ,
640+ detectDarkTheme : this . user . settings . detectDarkTheme ,
641+ } ,
630642 } ;
631643 }
632644 case ThemeEngines . dynamicTheme : {
633- const filter = { ...theme } ;
634- delete filter . engine ;
635645 const fixes = getDynamicThemeFixesFor ( url , frameURL , this . config . DYNAMIC_THEME_FIXES_RAW , this . config . DYNAMIC_THEME_FIXES_INDEX , this . user . settings . enableForPDF ) ;
636- const isIFrame = frameURL != null ;
637646 return {
638647 type : MessageType . BG_ADD_DYNAMIC_THEME ,
639- data : { filter, fixes, isIFrame} ,
648+ data : {
649+ theme,
650+ fixes,
651+ isIFrame,
652+ detectDarkTheme,
653+ } ,
640654 } ;
641655 }
642656 default : {
0 commit comments