import { PDFViewerApplication } from './viewer.mjs'; (async function () { const params = new URLSearchParams(location.search); const src = params.get('src'); if (!src) return; const resp = await browser.runtime.sendMessage({ type: "fetch-pdf", url: src }); if (resp.error) { document.body.innerText = "Failed to fetch PDF: " + resp.error; return; } const blobUrl = resp.blobUrl; console.log("Custom viewer: got blob URL", blobUrl); // Redirect with ?file= so that viewer.js bootstraps it natively const newUrl = location.origin + location.pathname + "?file=" + encodeURIComponent(blobUrl) + "&original_url=" + src location.replace(newUrl) })();