This Week's Sponsor:

Kolide

Ensure that if a device isn’t secure it can’t access your apps.  It’s Device Trust for Okta.


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↩︎

Unlock More with Club MacStories

Founded in 2015, Club MacStories has delivered exclusive content every week for over six years.

In that time, members have enjoyed nearly 400 weekly and monthly newsletters packed with more of your favorite MacStories writing as well as Club-only podcasts, eBooks, discounts on apps, icons, and services. Join today, and you’ll get everything new that we publish every week, plus access to our entire archive of back issues and downloadable perks.

The Club expanded in 2021 with Club MacStories+ and Club Premier. Club MacStories+ members enjoy even more exclusive stories, a vibrant Discord community, a rotating roster of app discounts, and more. And, with Club Premier, you get everything we offer at every Club level plus an extended, ad-free version of our podcast AppStories that is delivered early each week in high-bitrate audio.

Choose the Club plan that’s right for you:

  • Club MacStories: Weekly and monthly newsletters via email and the web that are brimming with app collections, tips, automation workflows, longform writing, a Club-only podcast, periodic giveaways, and more;
  • Club MacStories+: Everything that Club MacStories offers, plus exclusive content like Federico’s Automation Academy and John’s Macintosh Desktop Experience, a powerful web app for searching and exploring over 6 years of content and creating custom RSS feeds of Club content, an active Discord community, and a rotating collection of discounts, and more;
  • Club Premier: Everything in from our other plans and AppStories+, an extended version of our flagship podcast that’s delivered early, ad-free, and in high-bitrate audio.