Skip to content

Instantly share code, notes, and snippets.

@rmeekers
Last active November 23, 2016 16:04
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/4345fa5260a80ddbc5c877b7394bc50f to your computer and use it in GitHub Desktop.
Save rmeekers/4345fa5260a80ddbc5c877b7394bc50f to your computer and use it in GitHub Desktop.
Bookmarklet 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.
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