This Week's Sponsor:

Incogni

Put an End to Spam, Scams, and Robocalls on Your iPhone


Command-C Browser Actions

Command-C

Command-C

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.

Command-C to Tweetbot bookmarklet

javascript:window.location=('command-c://x-callback-url/copyText?deviceIndex=1&text='+escape('tweetbot://USERNAME/post?text='+encodeURIComponent(document.location.href)));

(Change “USERNAME” to your Twitter username for Tweetbot)

Command-C to Editorial bookmarklet

javascript:window.location=('command-c://x-callback-url/copyText?deviceIndex=1&text='+escape('editorial://?command=SimpleURL&input='+encodeURIComponent(document.location.href)));

(Requires SimpleURL workflow)

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.


  1. You can use the same code in Chrome or Firefox, iCab on iOS, or even as a JavaScript action in Editorial. It will work. ↩︎

  2. I haven’t tried this personally, but it could be done with a combination of SmartWatch+ and Keyboard Maestro↩︎

Access Extra Content and Perks

Founded in 2015, Club MacStories has delivered exclusive content every week for nearly a decade.

What started with weekly and monthly email newsletters has blossomed into a family of memberships designed every MacStories fan.

Learn more here and from our Club FAQs.

Club MacStories: Weekly and monthly newsletters via email and the web that are brimming with apps, tips, automation workflows, longform writing, early access to the MacStories Unwind podcast, periodic giveaways, and more;

Club MacStories+: Everything that Club MacStories offers, plus an active Discord community, advanced search and custom RSS features for exploring the Club’s entire back catalog, bonus columns, and dozens of app discounts;

Club Premier: All of the above and AppStories+, an extended version of our flagship podcast that’s delivered early, ad-free, and in high-bitrate audio.