Skip to content

Instantly share code, notes, and snippets.

@rogiervandenberg
Last active March 23, 2016 11:09
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 rogiervandenberg/5072b6d78d3239558242 to your computer and use it in GitHub Desktop.
Save rogiervandenberg/5072b6d78d3239558242 to your computer and use it in GitHub Desktop.
Bookmarklet to make a link in Omnifocus to the current Gmail e-mail. The body of the mail is added as note, when hightlighting text in the e-mail only that part is added as note. There is always a link included to the original e-mail.
javascript:(function(){var enc=encodeURIComponent,w=window,frames=w.frames,d=document,tn=w.getSelection?w.getSelection():(d.getSelection)?d.getSelection():(d.selection?d.selection.createRange().text:0),pu=w.location.href,isGMail=w.location.host.match(/mail\.google\.com/),tt=pt=d.title,subjSpans=d.getElementsByClassName("hP"),i,url;if(isGMail){if(subjSpans){tt=subjSpans[0].innerText}else{tt=d.title.substring(d.title.indexOf("-")+1,d.title.lastIndexOf("-")).replace(/^ +/,"").replace(/ +$/,"")};if(tn!="")tn+="\n\n";tn+="From email subject:("+tt+")\n"+pu;pu="https://mail.google.com/mail/u/0/?qs=true&search=query&q=subject:("+enc(tt)+")"};url='omnifocus:///add?note='+enc(tn+"\n"+pu)+'&name='+enc(tt);w.location.href=url})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment