Skip to content

Instantly share code, notes, and snippets.

@rmeekers
Created November 23, 2016 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmeekers/b19aa030c5b2032324362c442597a35b to your computer and use it in GitHub Desktop.
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.
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