ken107 / read-aloud

An awesome browser extension that reads aloud webpage content with one click
https://readaloud.app
MIT License
1.31k stars 227 forks source link

Feature Request: Read externally hosted PDFs by URL instead of upload (Firefox) #395

Open ArtofBugs opened 2 months ago

ArtofBugs commented 2 months ago

For the PDF viewer, it would be nice if we could enter a URL for a non-local PDF. For example, if I want to read https://docs.house.gov/billsthisweek/20240429/HR%204866%20-Garcia.pdf, I have to

  1. have my tab redirected to the lsd reader page
  2. go back a page to get back to the PDF
  3. download the PDF
  4. go back to the lsd reader
  5. upload the PDF there.

(Cryptically, some pages, like https://arxiv.org/pdf/1910.11099, give a "missing host permissions for the tab" error and don't redirect to the lsd reader at all, but I'd assume this falls under the same thing.)

It would be faster if there was a way to just enter the URL of the PDF page on the lsd reader page (or if the additional permissions are enabled, grab the URL automatically before the redirect).

ken107 commented 1 week ago

Have you tried simply clicking on the Read Aloud icon when you're at the URL https://docs.house.gov/billsthisweek/20240429/HR%204866%20-Garcia.pdf ? It should work without your having to go through the steps above. I just tried and it seems to work fine.

ArtofBugs commented 1 week ago

Have you tried simply clicking on the Read Aloud icon when you're at the URL https://docs.house.gov/billsthisweek/20240429/HR%204866%20-Garcia.pdf ? It should work without your having to go through the steps above. I just tried and it seems to work fine.

Yes I tried that first; it does not work for me.

ArtofBugs commented 1 week ago

I am on the latest version of Firefox; clicking the Read Aloud icon takes me to the pdf upload page instead of reading aloud the page.

ArtofBugs commented 1 week ago

@ken107 were you able to reproduce the error for the ArXiv link I mentioned above? Here it is again if you missed it: https://arxiv.org/pdf/1910.11099

ken107 commented 1 week ago

Ah, thanks for clarifying. I remember now. On Firefox, security prevents us from injecting code into the built-in PDF viewer page to load our own PDF viewer on top (the way we make it work on Chromium browsers). So we fall back to redirecting the user to the standalone viewer. The standalone viewer cannot open externally hosted PDF files from other websites due to cross-origin restrictions, hence the unfortunate steps you have to go through to make it work.

But thinking about it now, there may be a convoluted way to solve this. The extension reads the PDF file in the background, create a blob URL from it, and hands it down to the standalone viewer. The extension, if required, will need to request origin-permission to be able to read the PDF file.