Downloading the Dog:
The Art of Taking Shortcuts

The Background

Over the summer, my fiancée and I adopted a miniature poodle from a rescue organization.

His name is Tucker, and he is adorable.

I grew up with a dog, but this is the first time I’ve been directly responsible for one as an adult. My fiancée and I both work during the day, so one of the things I’ve had to learn to get used to is the idea of letting other people enter my home to take care of my canine child.

Thankfully, our dog walker takes two or three photos of Tucker each day, which provides a helpful reassurance that Tucker is out and about and doing just fine. (And just to clarify, this is not some crazy thing we requested; he does this for all his clients.)

The Problem

Our dog walker keeps us apprised of Tucker’s daily walks via a nifty website called DoTimely. We get an email notification from the site at the beginning and end of each walk. The end-of-walk notification includes a link to a status report that tells us whether Tucker has done his doggy business and, of course, allows us to view the photos.

I could probably have been content with that, but my fiancée likes to download each image to an iCloud photo album that she has shared with me and a bunch of other family members.

Recently, I discovered that she hasn’t actually been downloading the photos at all. She’s been taking screenshots on her iPhone, which she then crops down to the size of the photo.

It turns out that for some reason, when you access the DoTimely report on an iPhone, you can’t do the standard touch-and-hold maneuver that normally brings up Safari’s “Add to Photos” option. (Right-clicking works just fine on a Desktop.)

The Objective

While this procedure has apparently been working just fine for months, I wanted to see if we could somehow automate it to avoid having to take screenshots. We knew the website had to be loading the images from somewhere, so it would just be a matter of figuring out where and then downloading them ourselves.

The Solution

A few iterations of iOS ago, Apple released an app called Shortcuts. It allows you to create macros (automated software routines) that stitch together functions of different phone apps as well as some that are built into the operating system.

Creating a shortcut is like building a rudimentary computer program. You create a series of steps that passes the output of one function into the input of another. Conveniently, you can add these shortcuts to the sheet that pops up when you tap on the iOS share button. This allows you to pass almost anything (e.g. a Safari web page) in as input.

Using my desktop to analyze the source code of the DoTimely report pages, I discovered that Tucker’s photos always have the string “dotimelyappointment” in their URL. No other images that appear on the report have this text in their address.

So how could I use this information to scrape the photos from the page? After doing a little more digging, I discovered that the Shortcuts app has a function called “Run JavaScript on Webpage.”

Perfect! All I needed to do was create a few lines of JavaScript to gather up all the images and filter the list down to just the appropriate URLs:

// Find every image tag on the page
var imgs = document.getElementsByTagName("img");
// Create an empty array to hold the results
var urls = [];
// Loop through all the images found above
for (var i = 0; i < imgs.length; i++) {
    
    // If image URL contains the key phrase, add it to array
    if (imgs[i].src.includes("dotimelyappointment")) {
        urls.push(imgs[i].src);
    }
}
// Pass the array of URLs to the next step
completion(urls);

Now, I just needed to use a few of the shortcut app’s built-in functions to actually visit those URLs and obtain the photos:

And that’s it! When I run this shortcut from the share sheet…

…I’m greeted with a preview of each image:

If I want to keep it, I tap the save button in the corner. If I don’t, I tap “Done,” and it displays the next photo.

The Outcome

There are still a handful of taps involved, but I think it’s better than having to go through the trouble of screenshotting and cropping each photo.

If I ever wanted to reduce the number of taps, I could reprogram the shortcut to just automatically save the images to the phone’s photo album. This is easy enough, but I like the idea of being able to reject photos that we’re not interested in.

The Takeaway

If you’d like to use this shortcut yourself, follow the instructions below.

In its current form, it’s only useful for DoTimely users, but if you know how to modify the JavaScript, you can customize it to scrape images from other web pages. Just promise me you’ll only use this capability for good!

To use the shortcut, make sure you have iOS 13 or higher, and be sure you have a copy of the Shortcuts app on your phone.

You will also need to go into your Settings app, scroll down to the Shortcuts section, and turn on the option that says “Allow Untrusted Shortcuts.” (Note: Do this at your own risk. Apple provides a warning that this setting allows users to install shortcuts that could potentially be harmful or even steal personal information.)

Once you’ve set up the app, you can download the shortcut here. Enjoy!