@@ -214,34 +214,61 @@ export async function initContentScript(ctx: { onInvalidated: (cb: () => void) =
214214
215215 const truncatedQuote = quoteText . length > 150 ? quoteText . slice ( 0 , 150 ) + '...' : quoteText ;
216216
217- composeModal . innerHTML = `
218- <div class="compose-header">
219- <span class="compose-title">New Annotation</span>
220- <button class="compose-close">${ Icons . close } </button>
221- </div>
222- <div class="compose-body">
223- <div class="inline-compose-quote">"${ escapeHtml ( truncatedQuote ) } "</div>
224- <textarea class="inline-compose-textarea" placeholder="Write your annotation..."></textarea>
225- </div>
226- <div class="compose-footer">
227- <button class="btn-cancel">Cancel</button>
228- <button class="btn-submit">Post</button>
229- </div>
230- ` ;
217+ const header = document . createElement ( 'div' ) ;
218+ header . className = 'compose-header' ;
219+
220+ const titleSpan = document . createElement ( 'span' ) ;
221+ titleSpan . className = 'compose-title' ;
222+ titleSpan . textContent = 'New Annotation' ;
223+ header . appendChild ( titleSpan ) ;
224+
225+ const closeBtn = document . createElement ( 'button' ) ;
226+ closeBtn . className = 'compose-close' ;
227+ closeBtn . innerHTML = Icons . close ;
228+ header . appendChild ( closeBtn ) ;
229+
230+ composeModal . appendChild ( header ) ;
231+
232+ const body = document . createElement ( 'div' ) ;
233+ body . className = 'compose-body' ;
234+
235+ const quoteDiv = document . createElement ( 'div' ) ;
236+ quoteDiv . className = 'inline-compose-quote' ;
237+ quoteDiv . textContent = `"${ truncatedQuote } "` ;
238+ body . appendChild ( quoteDiv ) ;
239+
240+ const textarea = document . createElement ( 'textarea' ) ;
241+ textarea . className = 'inline-compose-textarea' ;
242+ textarea . placeholder = 'Write your annotation...' ;
243+ body . appendChild ( textarea ) ;
244+
245+ composeModal . appendChild ( body ) ;
246+
247+ const footer = document . createElement ( 'div' ) ;
248+ footer . className = 'compose-footer' ;
249+
250+ const cancelBtn = document . createElement ( 'button' ) ;
251+ cancelBtn . className = 'btn-cancel' ;
252+ cancelBtn . textContent = 'Cancel' ;
253+ footer . appendChild ( cancelBtn ) ;
254+
255+ const submitBtn = document . createElement ( 'button' ) ;
256+ submitBtn . className = 'btn-submit' ;
257+ submitBtn . textContent = 'Post' ;
258+ footer . appendChild ( submitBtn ) ;
259+
260+ composeModal . appendChild ( footer ) ;
231261
232262 composeModal . querySelector ( '.compose-close' ) ?. addEventListener ( 'click' , ( ) => {
233263 composeModal ?. remove ( ) ;
234264 composeModal = null ;
235265 } ) ;
236266
237- composeModal . querySelector ( '.btn-cancel' ) ? .addEventListener ( 'click' , ( ) => {
267+ cancelBtn . addEventListener ( 'click' , ( ) => {
238268 composeModal ?. remove ( ) ;
239269 composeModal = null ;
240270 } ) ;
241271
242- const textarea = composeModal . querySelector ( '.inline-compose-textarea' ) as HTMLTextAreaElement ;
243- const submitBtn = composeModal . querySelector ( '.btn-submit' ) as HTMLButtonElement ;
244-
245272 submitBtn . addEventListener ( 'click' , async ( ) => {
246273 const text = textarea ?. value . trim ( ) ;
247274 if ( ! text ) return ;
@@ -362,10 +389,14 @@ export async function initContentScript(ctx: { onInvalidated: (cb: () => void) =
362389
363390 const toast = document . createElement ( 'div' ) ;
364391 toast . className = `margin-toast ${ type === 'success' ? 'toast-success' : '' } ` ;
365- toast . innerHTML = `
366- <span class="toast-icon">${ type === 'success' ? Icons . check : Icons . close } </span>
367- <span>${ message } </span>
368- ` ;
392+ const iconSpan = document . createElement ( 'span' ) ;
393+ iconSpan . className = 'toast-icon' ;
394+ iconSpan . innerHTML = type === 'success' ? Icons . check : Icons . close ;
395+ toast . appendChild ( iconSpan ) ;
396+
397+ const msgSpan = document . createElement ( 'span' ) ;
398+ msgSpan . textContent = message ;
399+ toast . appendChild ( msgSpan ) ;
369400
370401 container . appendChild ( toast ) ;
371402
@@ -844,7 +875,7 @@ export async function initContentScript(ctx: { onInvalidated: (cb: () => void) =
844875 } ) ;
845876
846877 popoverEl . querySelectorAll ( '.btn-share' ) . forEach ( ( btn ) => {
847- btn . addEventListener ( 'click' , async ( e ) => {
878+ btn . addEventListener ( 'click' , async ( _e ) => {
848879 const text = ( btn as HTMLElement ) . getAttribute ( 'data-text' ) || '' ;
849880 try {
850881 await navigator . clipboard . writeText ( text ) ;
0 commit comments