diff --git a/popup.css b/popup.css index 7d8b850..2e51c1b 100644 --- a/popup.css +++ b/popup.css @@ -305,9 +305,17 @@ button:active { .footer { display: flex; - justify-content: flex-end; + justify-content: space-between; align-items: center; margin-top: 6px; + gap: 8px; +} + +.footer-left { + display: flex; + align-items: center; + gap: 6px; + flex-wrap: wrap; } .link { diff --git a/popup.html b/popup.html index 4b4e84a..a8f85c6 100644 --- a/popup.html +++ b/popup.html @@ -10,7 +10,7 @@
WWCompanion - Manual reasoning for WaterlooWorks + AI companion for WaterlooWorks.
@@ -43,6 +43,10 @@ diff --git a/popup.js b/popup.js index 867a91c..809d874 100644 --- a/popup.js +++ b/popup.js @@ -10,6 +10,8 @@ const statusEl = document.getElementById("status"); const postingCountEl = document.getElementById("postingCount"); const promptCountEl = document.getElementById("promptCount"); const settingsBtn = document.getElementById("settingsBtn"); +const copyRenderedBtn = document.getElementById("copyRenderedBtn"); +const copyRawBtn = document.getElementById("copyRawBtn"); const state = { postingText: "", @@ -432,11 +434,40 @@ function handleAbort() { setStatus("Aborted."); } +async function copyTextToClipboard(text, label) { + try { + await navigator.clipboard.writeText(text); + setStatus(`${label} copied.`); + } catch (error) { + setStatus(`Unable to copy ${label.toLowerCase()}.`); + } +} + +function handleCopyRendered() { + const text = outputEl.innerText || ""; + if (!text.trim()) { + setStatus("Nothing to copy."); + return; + } + void copyTextToClipboard(text, "Output"); +} + +function handleCopyRaw() { + const text = state.outputRaw || ""; + if (!text.trim()) { + setStatus("Nothing to copy."); + return; + } + void copyTextToClipboard(text, "Markdown"); +} + extractBtn.addEventListener("click", handleExtract); analyzeBtn.addEventListener("click", handleAnalyze); extractRunBtn.addEventListener("click", handleExtractAndAnalyze); abortBtn.addEventListener("click", handleAbort); settingsBtn.addEventListener("click", () => chrome.runtime.openOptionsPage()); +copyRenderedBtn.addEventListener("click", handleCopyRendered); +copyRawBtn.addEventListener("click", handleCopyRaw); updatePostingCount(); updatePromptCount(0);