Two days into using my OmniFocus text clipper and found I needed to make a revision. Now the clipper will pull the web page title, the URL, the copied text and concatenate them into a single note for OmniFocus. The updated code is below:
#Summary: Takes copied text and creates new task in OmniFocus
#By: Jason Verly
#Rev: 2013-02-04
#Rev Note: Added Page Title & URL to clipped txt
import webbrowser
import clipboard
import urllib
import console
import sys
title = sys.argv[1]
url = sys.argv[2]
task = console.input_alert('Task', 'Enter task description')
task = urllib.quote(task)
note = clipboard.get()
full_note = ''.join([title,'\n\n', url, '\n\n', note])
full_note = urllib.quote(full_note.encode('utf-8'))
webbrowser.open('omnifocus:///add?name=' + task + '¬e=' + full_note)
The new bookmark in Safari is:
javascript:window.location=’pythonista://ImportToOF?action=run&argv=’+encodeURIComponent(document.title)
+’&argv=’+encodeURIComponent(document.location.href)
The Pythonista script needs to be named the same as the script called out in the javascript bookmark. In the example above, the script would be named ‘ImportToOF’ in Pythonista. [1]
Running the OmniFocus clipper will now concatenate the page title, the page URL, and the selected text into one text block for the note section in OmniFocus. An example of the task is, as it was pulled into OmniFocus via the clipper action, looks like this:

-
Update: Included note regarding matching the name of the Pythonista script and the call out in the javascript bookmark. ↩


Jason,
This is great, thanks for sharing!
For those following at home, the curly quotes break the bookmarklet… so be sure to use:
javascript:window.location=’pythonista://ImportToOF?action=run&argv=’+encodeURIComponent(document.title)+’&argv=’+encodeURIComponent(document.location.href)
Also worth noting that the Pythonista file needs to be called “ImportToOF”.
Cheers,
Dan
p.s. Nevermind, the comment system turned mine into curlyquotes too. Regardless, just replace any instances of “%E2%80%99″ with a single apostrophe.
Thanks for pointing out the step about that the script needs to labeled, ‘ImportToOF’, in Pythonista. I’ll make an update note to the post soon.
Post updated with note about Pythonista script needs to be named the same as the script being called in the javascript bookmark.
Awesome work! Thanks for putting this script together.
Pingback: OmniFocus Clipper v2.0 | Thank You For Your Cooperation