Files
pdfjs_with_vimiumc/viewer-boot.js
2025-10-03 23:32:36 +08:00

22 lines
710 B
JavaScript

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)
})();