@@ -803,21 +803,23 @@ FIT-TO-WIN BUTTON
803
803
------------------------------------------------------------------------------*/
804
804
ImprovedTube . playerFitToWinButton = function ( ) {
805
805
if ( this . storage . player_fit_to_win_button === true && ( / w a t c h \? / . test ( location . href ) ) ) {
806
- let tempContainer = document . createElement ( "div" ) ;
807
-
806
+ if ( typeof trustedTypes !== 'undefined' && typeof trustedTypes . createPolicy === 'function' ) {
808
807
// Create a Trusted Type policy
809
808
const policy = trustedTypes . createPolicy ( 'default' , {
810
809
createHTML : ( string ) => string ,
811
810
} ) ;
812
811
813
812
// Use the policy to set innerHTML
814
813
tempContainer . innerHTML = policy . createHTML ( `
815
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" id="ftw-icon">
816
- <path d="M21 3 9 15"/><path d="M12 3H3v18h18v-9"/><path d="M16 3h5v5"/><path d="M14 15H9v-5"/>
817
- </svg>` ) ;
814
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" id="ftw-icon">
815
+ <path d="M21 3 9 15"/><path d="M12 3H3v18h18v-9"/><path d="M16 3h5v5"/><path d="M14 15H9v-5"/></svg>` ) ;
818
816
819
817
// Ensure the SVG element is correctly parsed
820
818
const svg = tempContainer . querySelector ( 'svg' ) ;
819
+ } else { let tempContainer = document . createElement ( "div" ) ;
820
+ tempContainer . innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" id="ftw-icon">
821
+ <path d="M21 3 9 15"/><path d="M12 3H3v18h18v-9"/><path d="M16 3h5v5"/><path d="M14 15H9v-5"/></svg>` ;
822
+ const svg = tempContainer . firstChild ; }
821
823
this . createPlayerButton ( {
822
824
id : 'it-fit-to-win-player-button' ,
823
825
child : svg ,
@@ -1506,4 +1508,4 @@ ImprovedTube.pauseWhileTypingOnYoutube = function () {
1506
1508
}
1507
1509
1508
1510
}
1509
- } ;
1511
+ } ;
0 commit comments