${text}`;
+ // Set content via textContent to avoid XSS from API responses or URL strings.
+ panel.innerHTML = ''; + panel.querySelector('strong').textContent = `Debug (${apiUrl})`; + panel.querySelector('pre').textContent = text; }
diff --git a/chrome-extension/content.js b/chrome-extension/content.js index 19141e7..8c93294 100644 --- a/chrome-extension/content.js +++ b/chrome-extension/content.js @@ -67,6 +67,29 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { } }); +// Convert a small subset of Markdown to HTML. +// Handles bold, italic, headings, inline code, unordered lists, and code fences. +function markdownToHtml(text) { + return text + // Strip wrapping code fences (```html ... ``` or ``` ... ```) + .replace(/^```(?:html)?\n?/gi, '').replace(/\n?```$/g, '') + // Headings + .replace(/^### (.*$)/gim, '
$1')
+ // Unordered list items (lines starting with "* " or "- ")
+ .replace(/^[*-] (.+)$/gim, '${text}`;
+ // Set content via textContent to avoid XSS from API responses or URL strings.
+ panel.innerHTML = '