first commit
This commit is contained in:
		
							
								
								
									
										21
									
								
								viewer-boot.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								viewer-boot.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
			
		||||
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)
 | 
			
		||||
 | 
			
		||||
})();
 | 
			
		||||
		Reference in New Issue
	
	Block a user