0

This may be really simple, since I can't use window.getSelection on iPhone Safari, I was wondering if I could put the selection in the clipboard and use a bookmarklet to send it to Drafts (among with location.href)

The first part of the equation is quite simple:

javascript:window.location='drafts://x-callback-url/create?text='+encodeURIComponent(location.href+'%5Cn%5Cn')

As I'm a rookie, I interpreter this "create a new document in Drafts and append the current window link to the top and press return twice", now I just need to add the contents from the clipboard into this.

If I simply use the Drafts short [[clipboard]]to add the clipboard, it won't work. So I'm suspicious that I'll need a Java solution. Ideas?

Phillip Gruneich
  • 120
  • 2
  • 10

2 Answers2

0

unfortunately, it seems like, according to the state of things as they are right now, this is impossible. I'm better off with the clipboard in the iPhone, it seems. Thank you for checking out.

The command I was looking for is available in the iPad, you can reach it through this:

javascript:window.location='drafts://x-callback-url/create?text='+encodeURIComponent(location.href+'%5Cn%5Cn')+encodeURIComponent(window.getSelection())

According to the article by Federico Viticci, this encodeURIComponent(window.getSelection()) being the snippet that grabs the actual selection.

This happens because when you open the bookmarks tab in the iPhone, it deselects your selection and the snippet becomes useless. In the iPad, you must keep the Always Show Bookmarks option on.

Phillip Gruneich
  • 120
  • 2
  • 10
0

The latest version of iCab Mobile has a variety of gestures, a draw-gesture feature, and a bookmarklet list called "Modules" that is (unofficially) customizable. On both the iPad and the iPhone, gesture recognition can execute JavaScript or launch apps by URL scheme without affecting your selection. It also happens to support x-callback-URL as well. :)