Created
August 24, 2011 23:31
-
-
Save al3xandru/1169583 to your computer and use it in GitHub Desktop.
OmniFocus Generalized Bookmarklet
This file contains hidden or 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
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 | |
})(); | |
// one liner: | |
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