3

I hope you are doing well in these hard times.

Now, I am trying to build a web extension for Firefox that can download a web page with a singe click. The requirement that I am struggling with is that is has to download all images from that page along with the page HTML document but without fetching them again from the server.

So the question is: is this even possible? I know the images are loaded in browser cache, so from my research, I could go about this in a few ways:

  1. Pull images from cache: Not sure if it possible to access cache from other pages and how?
  2. Get image data from image and draw them on blank canvas
  3. Intercept request to images and get the loaded data

Now, after all of this, I have to bulk download all images which complicates the problem further...

Any help on this?

UPDATE: So I decided to switch to Chrome and try the pageCapture API (thanks @wOxxOm for pointing out). Here I ran into a different kind of problem which I wrote in the follow-up question.

Thanks again for your help.

mrd
  • 73
  • 1
  • 2
  • 5
  • I think this was asked already so look more for an existing answer but in short there is no "post factum" solution for Firefox as it lacks chrome.pageCapture API and there's no way to poke its cache explicitly so your options are either refetching all images and hope they'll hit the cache (you can try forging their cache header via webRequest API but I'd expect the browser to ignore these manipulations) or preemptively read the original responses via browser.webRequest.filterResponseData. – wOxxOm Mar 24 '20 at 11:14
  • Are you looking for cache storage? https://developer.mozilla.org/en-US/docs/Web/API/CacheStorage – Lajos Arpad Mar 24 '20 at 11:20
  • CacheStorage is irrelevant as it's a content delivery mechanism for service workers. – wOxxOm Mar 24 '20 at 17:34
  • @mrd, to download the result of pageCapture you can use a link element, [examples](https://stackoverflow.com/questions/19327749/javascript-blob-filename-without-link). – wOxxOm Mar 24 '20 at 17:37
  • @wOxxOm Thanks much. That's useful once I get the blob. Right now I am unable to capture the page due to that permission error I described above. – mrd Mar 25 '20 at 08:13
  • I don't understand what you want to achieve and how it's related to the goal of saving a page with images. – wOxxOm Mar 25 '20 at 08:15

0 Answers0