This commit is contained in:
2026-08-05 21:39:14 -05:00
commit b8d7e732d5
13 changed files with 1791 additions and 0 deletions

98
popup.js Normal file
View File

@@ -0,0 +1,98 @@
"use strict";
const statusEl = document.getElementById("status");
const listEl = document.getElementById("urlList");
const openHistoryBtn = document.getElementById("openHistoryBtn");
function setStatus(message) {
statusEl.textContent = message;
}
function entryLabel(entry) {
return entry && entry.fullUrl ? "full candidate" : "preview fallback";
}
function buildRow(entry) {
const li = document.createElement("li");
li.className = "url-item";
const p = document.createElement("p");
p.className = "url-text";
p.textContent = entry.previewUrl || entry.fullUrl || "";
const status = document.createElement("p");
status.className = "status";
status.textContent = `Source: ${entry.source || "unknown"} | Mode: ${entryLabel(entry)}`;
const actions = document.createElement("div");
actions.className = "actions";
const download = document.createElement("button");
download.type = "button";
download.textContent = "Download";
download.addEventListener("click", async () => {
const result = await browser.runtime.sendMessage({ type: "DOWNLOAD_ENTRY", entry });
if (!result || !result.ok) {
window.alert((result && result.error) || "Download failed.");
return;
}
setStatus(result.mode === "full" ? "Downloaded full file URL." : "Downloaded decoded preview fallback.");
});
const copy = document.createElement("button");
copy.type = "button";
copy.className = "secondary";
copy.textContent = "Copy URL";
copy.addEventListener("click", async () => {
const url = entry.fullUrl || entry.previewUrl || "";
await navigator.clipboard.writeText(url);
});
actions.appendChild(download);
actions.appendChild(copy);
li.appendChild(p);
li.appendChild(status);
li.appendChild(actions);
return li;
}
async function loadCapturedUrls() {
const tabs = await browser.tabs.query({ active: true, currentWindow: true });
const activeTab = tabs[0];
if (!activeTab || typeof activeTab.id !== "number") {
setStatus("No active tab found.");
return;
}
const response = await browser.runtime.sendMessage({
type: "GET_TAB_URLS",
tabId: activeTab.id
});
if (!response || !response.ok) {
setStatus("Unable to load captured URLs.");
return;
}
listEl.innerHTML = "";
const entries = Array.isArray(response.entries) ? response.entries : [];
if (!entries.length) {
setStatus("No captured S3 URLs for this tab yet.");
return;
}
setStatus(`Captured samples for this tab: ${entries.length}`);
for (const entry of entries) {
listEl.appendChild(buildRow(entry));
}
}
openHistoryBtn.addEventListener("click", async () => {
await browser.runtime.sendMessage({ type: "OPEN_HISTORY" });
window.close();
});
loadCapturedUrls().catch(() => {
setStatus("Unexpected error while loading URLs.");
});