Scriptable: Clipboard URL to Markdown Link02 Nov 2018
With the move from Workflow to Shortcuts, I’ve come a little unstuck with a new issue around sharing them on iOS. Previously, if I wanted to get the name of a workflow and it’s URL in a Markdown link format, I could use a workflow to grab the title of the download page of the URL, which would match to the name of the workflow. After that it was just a case of wrapping the details in some Markdown syntax and we were done. Unfortunately that approach doesn’t work any more, but I have come up with a workaround utilising Scriptable.
What’s the Problem?
Quite simply, the download page is now dynamically built in a manner that means when the page first loads, the title is not correctly set. Only when additional page elements have been loaded does the entire page update to offer the download, and also title the page accordingly. Whenever I have tried to automate this on iOS, I’ve hit a limitation of the utility app being used grabbing the title of the first build of the page rather than the final build of the page. Nothing I tried got the system to wait appropriately.
What’s the Solution?
I start by sharing the iCloud link to a shortcut to the device clipboard. After that I trigger my Scriptable script (typically from Launch Center Pro). The Scriptable script receives the URL and passes it to a function called
MDLink. The function creates a web view and loads the URL from the clipboard into it. Once the page finished loading to the point where I can see that the title is set, I select the
The Scriptable script looks like this.
While this isn’t the fully automated solution I really want, it’ll do until Apple opens up something for Shortcuts that let’s me directly access both pieces of information, or a way to automate the wait without a manual intervention web view is available.