odin
April 23, 2024, 5:13pm
1
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?
Thanks
odin
tiffle
April 23, 2024, 8:10pm
2
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!)
-rob.
tiffle
April 23, 2024, 8:53pm
4
As an example here's a demo macro using your JavaScript with my KM plugin to download from the currently loaded web page.
When run on this web page https://pixelsnaps.photography it results in this in Finder:
I've just added information about my file-downloading plugins here:
If you want to download files from the Internet it makes sense to use a download manager app that will take care of all the details for you. If you want to automate the downloading of files using Keyboard Maestro (KM), you would do well to look at the Leech download manager application from Many Tricks Software because it can be controlled through the use of AppleScript.
The TFL Leech Control Suite is a set of four third party plug in actions for KM. The actions provide an easy way for KM users…
Riffing off of @tiffle 's macro, this works with curl.
download all images on webpage copy.kmmacros (7.4 KB)
1 Like
Thanks for this, @edjusted . I didn't think I needed (or even wanted) this but it's been fun to play with a version that works in the Front Browser.
I made a few changes:
Prompt for destination folder (and optionally create a new one)
Optionally filter the array to just JPEGs
Massage the array to eliminate brackets and quotes
Further massage the array to eliminate extra parameters (stuff following a '?')
Use a progress bar during the download instead of notifications
Eliminate the delay
Still a work in progress (I could add some filters, I suppose) but thanks again for the curl version.
Download All Images.kmmacros (10 KB)
1 Like
Very cool, @mrpasini !
For anyone who's interested, I also have another thread in this forum that goes into detail about issues dealing with destination paths with spaces, and an alternative to using curl.
Ah ha! I was looking for that discussion in this thread because I wanted to try the Get URL
action (which is tricky).
Here's the Get URL
version of the macro (which is a little smaller than the curl
version):
Download All Images.km.kmmacros (9.8 KB)