Skip to content

Commit

Permalink
Update player.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ImprovedTube committed Aug 14, 2024
1 parent 472897c commit abe2657
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions js&css/web-accessible/www.youtube.com/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -803,21 +803,23 @@ FIT-TO-WIN BUTTON
------------------------------------------------------------------------------*/
ImprovedTube.playerFitToWinButton = function () {
if (this.storage.player_fit_to_win_button === true && (/watch\?/.test(location.href))) {
let tempContainer = document.createElement("div");

if (typeof trustedTypes !== 'undefined' && typeof trustedTypes.createPolicy === 'function') {
// Create a Trusted Type policy
const policy = trustedTypes.createPolicy('default', {
createHTML: (string) => string,
});

// Use the policy to set innerHTML
tempContainer.innerHTML = policy.createHTML(`
<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">
<path d="M21 3 9 15"/><path d="M12 3H3v18h18v-9"/><path d="M16 3h5v5"/><path d="M14 15H9v-5"/>
</svg>`);
<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">
<path d="M21 3 9 15"/><path d="M12 3H3v18h18v-9"/><path d="M16 3h5v5"/><path d="M14 15H9v-5"/></svg>`);

// Ensure the SVG element is correctly parsed
const svg = tempContainer.querySelector('svg');
} else { let tempContainer = document.createElement("div");
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">
<path d="M21 3 9 15"/><path d="M12 3H3v18h18v-9"/><path d="M16 3h5v5"/><path d="M14 15H9v-5"/></svg>`;
const svg = tempContainer.firstChild;}
this.createPlayerButton({
id: 'it-fit-to-win-player-button',
child: svg,
Expand Down Expand Up @@ -1506,4 +1508,4 @@ ImprovedTube.pauseWhileTypingOnYoutube = function () {
}

}
};
};

0 comments on commit abe2657

Please sign in to comment.