1

I'm using Firefox 81 (and also 82 dev edition), and I'd like to be able to save the images on the page that has finished loading without sending another GET request. This is because:

  1. I don't want to wait for it to get downloaded again on a slow enough connection where it gets rather annoying,
  2. It may not get downloaded again using the same url due to overprotective coding of the page (one-time url tokens),
  3. The site may temporarily block me from using it, due to excessive security measures. Such are the internal business sites.

Making screenshots of a page is not a good option because images are often larger than the screen and require zooming in to view the full contents (like giant Gantt graphs and waterfall diagrams).

For whatever reason, some of the images on the page can be viewed via "View Page Info > Media tab" but even though the image that I want to save is displayed right there, it says that its size is "Unknown (not cached)". And when I attempt to save it by pressing "Save As..." the download tab shows that the file failed to download or it's 0 bytes long (just like the normal right click on the image and "Save image as"), and if I examine the GET response, it appears that Firefox didn't try to save it from memory or cache, but attempted to get it again, and sometimes it does not work.

Because legacy methods and extensions/addons are not compatible with modern Firefox versions, I'm asking for a modern day method of saving images which have already been downloaded and are displayed on a page. Is there a button in some menu for this? Is there a pure javascript function? Or maybe a userscript GM_something method? Or maybe an addon-only function that works in Firefox 81?

I could work with either a direct "Save to file" button or a function that returns a binary array of the original file, or a base64 string of it. I am aware of a method using canvas, but due to CSP/CORS it is usually impossible to send the resulting canvas bytes, and even when it works, the file is usually larger because it's not the original but the canvas redrawn version, and I'd like to get the original file if possible.

4
  • The answer would be kinda long for the scope o stackexchange, but basically what you need is to create canvas, draw the image in question to it and then get the binary data and download that. Commented Oct 8, 2020 at 15:04
  • @TomášZato-ReinstateMonica that type of answer already exists on SE, multiple times, and I already noted in my question that I am aware of it, and it doesn't work most of the time due to CSP protections on the page, and when it does, it's still undesirable. Commented Oct 8, 2020 at 20:21
  • You may be able to bypass CORS using GM.xmlHttpRequest Commented Oct 9, 2020 at 14:55
  • @TomášZato-ReinstateMonica I tried using it vs the vanilla js XHR class, but the result is the same. I also tried the option "Modify existing content security policy (CSP) headers:" in Tampermonkey but it doesn't work. What works is an extension that disables CSP headers globally, but I would like to disable them specific pages only (or better add my domain, instead of removing everything), and I haven't found an extension that supports that yet. Still, it produces a re-drawn image version on the canvas, and not the original image. The resulting file size and bytes don't match the original. Commented Oct 9, 2020 at 17:39

1 Answer 1

0

I've been trying to solve this problem for a while now and only method that consistently "worked" was to copy image to clipboard and paste it to MS Paint and then save. I know that this is far from what we want, but just wanted to share my findings on the matter. This operation did not trigger network activity.

I think that downloading images is flawed internally in the browsers, as I was testing the matter by downloading a big image (78 MB) with "Save as", many times, and I could see network activity in the Task Manager every time I did it.

Or maybe the image was just to big and there is some threshold of size above which browser doesn't cache images. Hard to tell.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .