Download all images on a web page

I found the "execute javascript in front browser" and added this action:

const imgUrls = Array.from(document.querySelectorAll('img')).map(img => img.src);

To get all the image urls into an array. Now,k I want to copy all the images to the clipboard and I am lost. Is this something that can be done? How do I accomplish such a thing?


The approach I take is to download the images as separate files on my Mac's disk using the AppleScriptable app called Leech. To make things even simpler I've created a third-party plugin action for KM that sends URLs to Leech for downloading.

I'd be happy to share if not getting images into the clipboard is something you can live with!

Wait, you what? Very cool—please message me, we could distribute this on our site with Leech for those interested! (If you wouldn't mind, of course!)


As an example here's a demo macro using your JavaScript with my KM plugin to download from the currently loaded web page.

Keyboard Maestro Export

When run on this web page it results in this in Finder: