Due Clipper For Google Chrome

When there are no actual news or notable app releases, I prefer investing my time in creating something for other people.

Continuing my ongoing series of tips on iOS URL schemes, here’s an adaptation of my existing Due bookmarklet to work better with Google Chrome for iOS (which, as I’ve pointed out several times, has a very nice URL scheme). The following code (to install it, simply copy it and paste the entire string into a bookmark) grabs a webpage’s title and URL and sends them to Due (also powered by a great URL scheme).

Thanks to x-callback-url, we can specify URLs to open in case of “error” (Due couldn’t create a new reminder) or “success” (Due created a new reminder and automatically showed the “Reminder” entry screen). In case of error, I personally decide to stay in Due; if the bookmarklet succeeds, I like to be taken back to Google Chrome after I tap the Add button.

javascript:window.location='due://x-callback-url/add?title='+encodeURIComponent(document.title)+'%20'+encodeURIComponent(document.location.href)+'&x-source=Google%20Chrome&x-error=due%3A%2F%2Fx-callback-url%2F&x-success=googlechrome%3A%2F%2F'

As you can see above, in the x-success parameter I’m using googlechrome%3A%2F%2F – which is simply the encoded version of googlechrome:// (those scary characters give it the convenient name of percent-encoding). You can play around with encoding and decoding strings using tools like this. Because x-callback-url’s fields want encoded strings, I’m doing the same with due%3A%2F%2Fx-callback-url%2F and Google%20Chrome. Not encoding strings properly is one of the most common mistakes I kept making when I first started using x-callback-url.

(Question: Why am I using googlechrome:// instead of a full webpage URL? As far as I know, the URL scheme alone can’t reload an existing tab, even when relaunching the same URL (unlike Safari). Therefore, to simply “jump back” to Chrome, I, well, re-open Chrome.)

A note about the screenshot in this post: the dialog box is generated by Due using x-source – a parameter to give a friendly name to the “calling app” (in our case, Google Chrome). Unfortunately, though, we can’t give x-error and x-success different pretty names; both parameters will use the x-source name given in Due. That’s why, even if you want to launch Due, the dialog box will keep saying “Google Chrome”.

Interestingly, the bookmarklet works on Safari for Mac, but not on Chrome (obviously, you won’t be able to rely on x-callback-url on the desktop). You can read more about Due’s URL scheme here, and check out a quick demo video of the bookmarklet below.