Created
November 23, 2016 16:05
-
-
Save rmeekers/b19aa030c5b2032324362c442597a35b to your computer and use it in GitHub Desktop.
Applescript to send Gmail email to Omnifocus. Email subject will become the action title. A link to the email will be added to the action notes. If you've selected some text, it will be added to the notes as well.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "Google Chrome" to tell active tab of front window to set the URL to " | |
javascript: (function() { | |
var enc = encodeURIComponent, | |
w = window, | |
frames = w.frames, | |
d = document, | |
ms = w.getSelection ? w.getSelection() : (d.getSelection) ? d.getSelection() : (d.selection ? d.selection.createRange().text : 0), | |
mu = w.location.href, | |
mt = d.title, | |
subjSpans = d.getElementsByClassName('hP'), | |
i, url; | |
if (subjSpans) { | |
mt = subjSpans[0].innerText | |
} else { | |
mt = d.title.substring(d.title.indexOf('-') + 1, d.title.lastIndexOf('-')).replace(/^ +/, '').replace(/ +$/, '') | |
}; | |
an = mu + '\n\n' + ms; | |
url = 'omnifocus:///add?note=' + enc(an) + '&name=' + enc(mt); | |
w.location.href = url | |
})(); | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment