I realize that Firefox already has built-in PDF support, but I’m trying to develop an add-on to replace the default viewer. When the user clicks on a PDF link, I want it to open in my add-on.
The downside would be that the final link isn’t so clean.
Replace the content of the PDF response with your PDF viewer. Means it gets displayed for the URL the PDF is at, but also breaks “Save page as”.
I’m not sure exactly what you mean by “the content of the PDF response”. Would I replace the GET results of the HTTP call to the PDF, and with what? Can you say more?
It would redirect to moz-extension://{local-guid}/viewer.html?url=https://example.com. As such the page is local and not remote.
The code of your viewer, so likely the HTML and the required bootstrap data. Since replacing the content of a request means you also get to read the original data, you can easily send the PDF data to the viewer afterward.