Skip to content

Commit abe2657

Browse files
authored
Update player.js
1 parent 472897c commit abe2657

File tree

1 file changed

+8
-6
lines changed
  • js&css/web-accessible/www.youtube.com

1 file changed

+8
-6
lines changed

js&css/web-accessible/www.youtube.com/player.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -803,21 +803,23 @@ FIT-TO-WIN BUTTON
803803
------------------------------------------------------------------------------*/
804804
ImprovedTube.playerFitToWinButton = function () {
805805
if (this.storage.player_fit_to_win_button === true && (/watch\?/.test(location.href))) {
806-
let tempContainer = document.createElement("div");
807-
806+
if (typeof trustedTypes !== 'undefined' && typeof trustedTypes.createPolicy === 'function') {
808807
// Create a Trusted Type policy
809808
const policy = trustedTypes.createPolicy('default', {
810809
createHTML: (string) => string,
811810
});
812811

813812
// Use the policy to set innerHTML
814813
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>`);
818816

819817
// Ensure the SVG element is correctly parsed
820818
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;}
821823
this.createPlayerButton({
822824
id: 'it-fit-to-win-player-button',
823825
child: svg,
@@ -1506,4 +1508,4 @@ ImprovedTube.pauseWhileTypingOnYoutube = function () {
15061508
}
15071509

15081510
}
1509-
};
1511+
};

0 commit comments

Comments
 (0)