@@ -64,7 +64,7 @@ async function initPopup() {
6464
6565 // PDF Check
6666 try {
67- await checkPDF ( hasPerms )
67+ await processFileTypes ( hasPerms )
6868 } catch ( e ) {
6969 console . debug ( e )
7070 }
@@ -76,7 +76,7 @@ async function initPopup() {
7676 // }
7777}
7878
79- async function checkPDF ( hasPerms ) {
79+ async function processFileTypes ( hasPerms ) {
8080 const [ tab ] = await chrome . tabs . query ( { active : true } )
8181 console . debug ( 'tab:' , tab )
8282 const url = new URL ( tab . url )
@@ -85,30 +85,29 @@ async function checkPDF(hasPerms) {
8585 // console.debug('browser:', browser)
8686 if ( url . pathname . toLowerCase ( ) . endsWith ( '.pdf' ) ) {
8787 console . debug ( `Detected PDF: ${ url . href } ` )
88- if ( [ 'firefox' , 'edge' ] . includes ( browser . id ) ) {
89- if ( url . protocol === 'file: ' ) {
90- const el = document . getElementById ( 'file-access' )
88+ if ( url . protocol === 'file:' ) {
89+ if ( browser . id === 'firefox ' ) {
90+ const el = document . getElementById ( 'no- file-access' )
9191 el . querySelector ( 'span' ) . textContent = browser . name
9292 el . classList . remove ( 'd-none' )
9393 return
9494 }
95- if ( ! hasPerms ) {
96- document
97- . getElementById ( 'firefox-pdf' )
98- . classList . remove ( 'd-none' )
99- return
100- }
101- } else if ( url . protocol === 'file:' ) {
10295 const fileAccess =
10396 await chrome . extension . isAllowedFileSchemeAccess ( )
10497 console . debug ( 'fileAccess:' , fileAccess )
10598 if ( ! fileAccess ) {
10699 document
107- . getElementById ( 'chrome-files ' )
100+ . getElementById ( 'file-access ' )
108101 . classList . remove ( 'd-none' )
109102 return
110103 }
111104 }
105+ if ( ! hasPerms ) {
106+ if ( browser . id === 'firefox' ) {
107+ document . getElementById ( 'pdf-perms' ) . classList . remove ( 'd-none' )
108+ return
109+ }
110+ }
112111 pdfBtn . dataset . pdfUrl = url . href
113112 pdfBtn . classList . remove ( 'd-none' )
114113 pdfBtn . addEventListener ( 'click' , extractPDF )
@@ -132,7 +131,11 @@ async function extractPDF(event) {
132131 window . close ( )
133132 } catch ( e ) {
134133 console . log ( 'e:' , e )
135- showToast ( e . message , 'danger' )
134+ if ( e . message === 'Promise.withResolvers is not a function' ) {
135+ showToast ( 'This browser does not support pdf.js' , 'danger' )
136+ } else {
137+ showToast ( e . message , 'danger' )
138+ }
136139 } finally {
137140 pdfIcon . classList . remove ( 'fa-sync' , 'fa-spin' )
138141 pdfIcon . classList . add ( 'fa-flask' )
0 commit comments