There's probably a way to do this with JavaScript, but my solution would be to use a shell script and lynx
The macro would need to get to the URL field (keystroke: β L) and then copy the URL to the clipboard (keystroke: β C) and then have this script run:
#!/bin/zsh -f
if [[ -e "$HOME/.path" ]]
then
source "$HOME/.path"
else
PATH='/usr/local/scripts:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin'
fi
cd ~/Downloads/
lynx -listonly -dump -nomargins -nonumbers "`pbpaste`" \
| egrep -i '\.(png|jpg|jpeg)$' \
| while read line
do
curl --remote-name -sfL "$line"
done
exit 0
# EOF
That will download all of the linked png / jpg / jpeg files on the current page to ~/Downloads/
Of course you'd also have to have lynx installed, which isn't a default part of OS X (I assume for some sort of license reason) but you can get it easily via Homebrew.
But someone else will probably post a better JavaScript alternative that doesn't require Unix tools.
@tjluoma Thank you for the suggestion, i see that @ccstone has an answer in another topic to return links containing specified format in GC and it does the work!
@ccstone
I need your help to modify the script to return image links in Safari
Many many thanks in advance!
If all of the images's URLs end with "_govermnet-id.jpeg", which I'm inferring they do from your examples, then this sequence of actions ought to retrieve all of the images source URLs containing that portion of text in them, store them in a variable, one per line, then iterate through the lines and open each URL in a Safari tab.
Array.from(document.images, x => x.src)
.filter(e => e.indexOf("_government-id.jpeg") != -1)
.join("\n");
I obviously cannot test it with your specific website, but I did a trial run on this page, looking for image URLs that contain the word "letter" and, indeed, I got all the images of "K" opening up in their own tabs (which are the letter_avatar_proxy images used for site users with no avatar uploaded)...um, anyway, it worked.