Skip to content

Instantly share code, notes, and snippets.

@al3xandru
Created August 5, 2011 21:51
Show Gist options
  • Save al3xandru/1128606 to your computer and use it in GitHub Desktop.
Save al3xandru/1128606 to your computer and use it in GitHub Desktop.
nvALT Bookmarklet
javascript:(function({
var INSTAPAPER=true,w=window,d=document,pageSelectedTxt=w.getSelection?w.getSelection():(d.getSelection)?d.getSelection():(d.selection?d.selection.createRange().text:0),pageTitle=d.title,pageUri=w.location.href,tmplt="";
tmplt="From ["+pageTitle+"]("+pageUri+"):\n\n";
if(pageSelectedTxt!="") {
pageSelectedTxt=">%20"+pageSelectedTxt;
pageSelectedTxt=pageSelectedTxt.replace(/(\r\n|\n+|\r)/gm,"\n");
pageSelectedTxt=pageSelectedTxt.replace(/\n/g,"\n>%20\n>%20");
w.location.href="nvalt://make/?txt="+encodeURIComponent(tmplt+pageSelectedTxt)+"&title="+encodeURIComponent(pageTitle)
}
else {
if(INSTAPAPER) {
pageUri="http://www.instapaper.com/m?u="+encodeURIComponent(pageUri)
};
w.location.href="nvalt://make/?url="+encodeURIComponent(pageUri)+"&title="+encodeURIComponent(pageTitle)
}
})();
@mxgrn
Copy link

mxgrn commented Apr 17, 2013

The uncompressed JS part fails to evaluate in Firebug console.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment