File tree Expand file tree Collapse file tree 5 files changed +9
-5
lines changed
Expand file tree Collapse file tree 5 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -107,7 +107,8 @@ export const onRendererLoad = ({
107107
108108 ipc . on ( 'downloader-feedback' , ( feedback : string ) => {
109109 if ( progress ) {
110- progress . innerHTML = feedback || t ( 'plugins.downloader.templates.button' ) ;
110+ const targetHtml = feedback || t ( 'plugins.downloader.templates.button' ) ;
111+ progress . innerHTML = window . trustedTypes ?. defaultPolicy ? window . trustedTypes . defaultPolicy . createHTML ( targetHtml ) : targetHtml ;
111112 } else {
112113 console . warn (
113114 LoggerPrefix ,
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ export const onRendererLoad = ({
1010 ipc : { invoke, on } ,
1111} : RendererContext < LyricsGeniusPluginConfig > ) => {
1212 const setLyrics = ( lyricsContainer : Element , lyrics : string | null ) => {
13- lyricsContainer . innerHTML = `
13+ const targetHtml = `
1414 <div id="contents" class="style-scope ytmusic-section-list-renderer description ytmusic-description-shelf-renderer genius-lyrics">
1515 ${
1616 lyrics ?. replaceAll ( / \r \n | \r | \n / g, '<br/>' ) ??
@@ -20,6 +20,7 @@ export const onRendererLoad = ({
2020 <yt-formatted-string class="footer style-scope ytmusic-description-shelf-renderer" style="align-self: baseline">
2121 </yt-formatted-string>
2222 ` ;
23+ lyricsContainer . innerHTML = window . trustedTypes ?. defaultPolicy ? window . trustedTypes . defaultPolicy . createHTML ( targetHtml ) : targetHtml ;
2324
2425 if ( lyrics ) {
2526 const footer = lyricsContainer . querySelector ( '.footer' ) ;
Original file line number Diff line number Diff line change @@ -22,7 +22,8 @@ const updatePlayBackSpeed = () => {
2222
2323 const playbackSpeedElement = document . querySelector ( '#playback-speed-value' ) ;
2424 if ( playbackSpeedElement ) {
25- playbackSpeedElement . innerHTML = String ( playbackSpeed ) ;
25+ const targetHtml = String ( playbackSpeed ) ;
26+ playbackSpeedElement . innerHTML = window . trustedTypes ?. defaultPolicy ? trustedTypes . defaultPolicy . createHTML ( targetHtml ) : targetHtml ;
2627 }
2728} ;
2829
Original file line number Diff line number Diff line change 66export const ElementFromHtml = ( html : string ) : HTMLElement => {
77 const template = document . createElement ( 'template' ) ;
88 html = html . trim ( ) ; // Never return a text node of whitespace as the result
9- template . innerHTML = html ;
9+ template . innerHTML = window . trustedTypes ?. defaultPolicy ? window . trustedTypes . defaultPolicy . createHTML ( html ) : html ;
1010
1111 return template . content . firstElementChild as HTMLElement ;
1212} ;
Original file line number Diff line number Diff line change @@ -269,7 +269,8 @@ const defineYTMDTransElements = () => {
269269 const that = this as HTMLElement ;
270270 const key = that . getAttribute ( 'key' ) ;
271271 if ( key ) {
272- that . innerHTML = i18t ( key ) ;
272+ const targetHtml = i18t ( key ) ;
273+ that . innerHTML = window . trustedTypes ?. defaultPolicy ? window . trustedTypes . defaultPolicy . createHTML ( targetHtml ) : targetHtml ;
273274 }
274275 } ;
275276 customElements . define (
You can’t perform that action at this time.
0 commit comments