@@ -17,11 +17,20 @@ document.addEventListener("DOMContentLoaded", () => {
1717 return ;
1818 }
1919 const container = document . getElementById ( "popupContent" ) ;
20- container . innerHTML = `
21- <h3>Problem: ${ data . title } </h3>
22- <p>Difficulty: ${ data . difficulty } </p>
23- <p id="status"><strong>${ data . status || "Unsolved" } </strong></p>
24- ` ;
20+
21+ container . innerHTML = "" ;
22+ const titleEl = document . createElement ( "h3" ) ;
23+ titleEl . textContent = `Problem: ${ data . title } ` ;
24+ const diffEl = document . createElement ( "p" ) ;
25+ diffEl . textContent = `Difficulty: ${ data . difficulty } ` ;
26+ const statusEl = document . createElement ( "p" ) ;
27+ statusEl . id = "status" ;
28+ const strongEl = document . createElement ( "strong" ) ;
29+ strongEl . textContent = data . status || "Unsolved" ;
30+ statusEl . appendChild ( strongEl ) ;
31+ container . appendChild ( titleEl ) ;
32+ container . appendChild ( diffEl ) ;
33+ container . appendChild ( statusEl ) ;
2534
2635 // Listen for problem solved message
2736 browser . runtime . onMessage . addListener ( ( msg ) => {
@@ -97,15 +106,27 @@ document.addEventListener("DOMContentLoaded", () => {
97106 const item = document . createElement ( "div" ) ;
98107 item . className = "problem-item" ;
99108 const difficultyClass = problem . difficulty ? problem . difficulty . toLowerCase ( ) : "" ;
100- // Show tags if available
101- const tagsHtml = Array . isArray ( problem . tags ) && problem . tags . length > 0
102- ? `<span style='font-size:0.85em; color:#666; margin-left:8px;'>[${ problem . tags . join ( ", " ) } ]</span>`
103- : "<span style='font-size:0.85em; color:#bbb; margin-left:8px;'>[No tags]</span>" ;
104- item . innerHTML = `
105- <a href="${ problem . url } " target="_blank">${ problem . title } </a>
106- <span class="difficulty ${ difficultyClass } ">${ problem . difficulty } </span>
107- ${ tagsHtml }
108- ` ;
109+ // Use DOM methods instead of innerHTML for safety
110+ const link = document . createElement ( 'a' ) ;
111+ link . href = problem . url ;
112+ link . target = '_blank' ;
113+ link . textContent = problem . title ;
114+
115+ const diffSpan = document . createElement ( 'span' ) ;
116+ diffSpan . className = `difficulty ${ difficultyClass } ` ;
117+ diffSpan . textContent = problem . difficulty ;
118+
119+ const tagsSpan = document . createElement ( 'span' ) ;
120+ tagsSpan . style . fontSize = '0.85em' ;
121+ tagsSpan . style . color = problem . tags && problem . tags . length > 0 ? '#666' : '#bbb' ;
122+ tagsSpan . style . marginLeft = '8px' ;
123+ tagsSpan . textContent = problem . tags && problem . tags . length > 0
124+ ? `[${ problem . tags . join ( ', ' ) } ]`
125+ : '[No tags]' ;
126+
127+ item . appendChild ( link ) ;
128+ item . appendChild ( diffSpan ) ;
129+ item . appendChild ( tagsSpan ) ;
109130 list . appendChild ( item ) ;
110131 } ) ;
111132 }
0 commit comments