This week's sponsor

Command-C Browser Actions

When I'm writing on my iPad at home, there's a chance I have my MacBook on my desk with either iTunes open (to check for app updates or playing music from iTunes Match/Radio) or MailMate running (because I've been having issues with Mail on the beta of iOS 7.1). It's not uncommon for me to use a dual-monitor setup when writing, relying on my MacBook for Google searches and other reference material – effectively, I use it as a secondary display to my iPad when I'm working on articles that require a fair amount of research.

Since the release of Command-C, I've been using Danilo Torrisi's utility to quickly beam text and URLs across all my devices, using Launch Center Pro actions to speed up the process. Command-C has excellent support for URL schemes – a boon to iPad users who fiddle with automation tricks to save time when working on iOS. I recently realized, however, that most of the content I share with Command-C is made of URLs from Safari, therefore I asked myself whether I could put together a solution to send URLs with one click from Safari without using an external app or keyboard shortcut. It was pretty clear from the beginning that I would end up with a bookmarklet, but I have to thank Danilo for providing the necessary guidance I needed to achieve the kind of workflow I wanted.

The bookmarklet is part made for myself, part proof of concept (as always) for others to iterate upon. It doesn't only send URLs from Safari on another device with Command-C – it sends the webpage you're currently viewing in Safari to another app on another device with Command-C.

In my examples, you can install the bookmarklet in Safari and click it to:

Send a webpage from Device A to start a new tweet in Tweetbot on Device B;

Send a webpage from Device A to open it in Editorial's browser on Device B.

The bookmarklets required a bit of back and forth between myself and Torrisi to get them to work – essentially, the fact that we're telling Safari to send the webpage to a specific app on another device can create issues with encoding, which needs the escape function to work properly. Also note that the deviceIndex parameter will have to be changed depending on your Command-C setup, so please refer to the Command-C documentation for futher instructions.

The technique is flexible in that it works in the browser1, on both iOS and OS X, and can be used as a template to invoke specific actions remotely in any app. In theory, if you have a Pebble and some free time, you should be able to create a workflow that lets you push a button on your wrist and send a webpage from Safari on your Mac to Tweetbot on your iPhone, Bond-style.2

Because the actions live in the browser as bookmarklets, you don't need an external launcher like Alfred, AppleScript, or Keyboard Maestro – just click them in the bookmarks bar, and Command-C will fire off a notification on your other device, which you can tap to perform the action.

As usual with URL scheme workflows and iOS, all this is handy and automated, but still a workaround meant for advanced users. Feel free to modify the code above, and if you create something different off of it, I'd love to know.

Federico is the founder and Editor-in-Chief of MacStories, where he writes about Apple with a focus on apps, developers, and iOS productivity. He founded MacStories in April 2009 and has been writing about Apple since. Federico is also the co-host of AppStories, a weekly podcast exploring the world of apps.