Automating the Mac App Store Purchased Apps List

The Mac App Store used to have a “Debug” menu:

which you used to be able to enable via

	defaults write ShowDebugMenu -bool true

Unfortunately the feature was removed in macOS Sierra (10.12), but I have an iMac (24-inch Mid 2007) which is still going strong, although it can’t run anything later than OS X El Capitan (10.11). I use it for running some older apps like Audio Hijack Pro (which still has automation features that its otherwise-awesome replacement Audio Hijack 3 still lacks).

So I still have access to a Mac which can use the App Store with the debug menu enabled.

The Problem

To me, the best feature of the App Store’s debug menu was the ability to save a page as an HTML file. That being said, it was an odd little feature, and I’m not sure what the use-case for it was supposed to be.

What I liked about it was that it allowed me to make a useful web page out of the “Purchased” page.

In the app, the “Purchased” tab is fine, as long as you are looking for an app that you purchased relatively recently. Otherwise, the page is nearly useless, since it can’t be searched, and can be set to alphabetical. It’s stuck in a reverse-chronological list of apps that you’ve purchased.

The Solution (Overview)

My current setup is the result of a little automation and some shell scripting. Oh, and Dropbox. (Where would we be without Dropbox?)

It works like this:

When I buy an app, I screen-share to my iMac using Screens which works 100% of the time, thanks to Screens Connect.

I leave the App Store app running, and open to the Purchased page. I refresh the page (⌘R) and make sure that the latest purchase appears at the top of the page. When it does, I select the Debug menu and choose “Save page source to disk” (⌘U).

(Aside: that’s the last step that I have to do. Everything else happens behind the scenes.)

A file is then created at:


which we can all agree is a strange place to save the file, but hey, it’s not as if Apple really expected people to be using this debug menu.

On the iMac, I create a launchd .plist using LaunchControl to watch for that file to be created.1 When it sees it, the file is moved to ~/Dropbox/Action/pageSource.html which then syncs to all of my other Macs.

Then my Mac mini at MacStadium takes over. It has Hazel running and one of the things Hazel looks for is a file at ~/Dropbox/Action/pageSource.html.

Once it sees it, it runs a shell script that I wrote which does the following:

  1. Parses Apple’s Mac App Store HTML using tidy (I could have used brew to install tidy-html5 but I could achieve what I wanted with the stock tidy, so I did.)

  2. Throws away parse of the file I don’t want using sed

  3. Loops through the rest of the file running awk to create one (tidy’ed) HTML file for each app that I have purchased, so that it can be more easily parsed with things like grep and sed

  4. Outputs the app information as (multi)markdown to a file

  5. Sorts the (multi)markdown to a file alphabetically

  6. Converts the (multi)markdown file to HTML

  7. Sends me a push notification using Pushover to tell me that has been updated.

The Behind-The-Scenes Part

Some of the apps that I have purchased over the years are no longer available for sale in the Mac App Store, but they can still be downloaded from the “Purchased” tab.

(Aside: There are also some apps that are no longer available for sale and which can no longer be downloaded, but that’s another rant for another day.)

I wanted to make sure that my page would differentiate between these “dead” apps and the “live” ones. Previously, I was doing that by making a https connection to Apple’s website for each app to see if the page was available or not. The whole script took about 4 minutes to run.

Re-writing the script to try to work-around some bugs led me to figure out how to tell “dead or alive” status from the HTML document from the Mac App Store, meaning that the current script doesn’t need to make any connections to Apple’s servers. The new script completes in about 40 seconds.

  1. I could have used Hazel for this, but it’s a simple enough thing for launchd to handle, so I used that instead.  ↩