Skip to content

Instantly share code, notes, and snippets.

@mxgrn
Forked from billygoat/gist:5320505
Last active October 19, 2018 02:19
Show Gist options
  • Save mxgrn/5402155 to your computer and use it in GitHub Desktop.
Save mxgrn/5402155 to your computer and use it in GitHub Desktop.
Adds a new entry in nvALT, with title set to page title, tags set to "bookmarks", and body containing page title, link, and text selected on page (if present).
/* Source code */
javascript:(function(){
var 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="Title: "+pageTitle+"\nLink: "+pageUri+"\n";
if (pageSelectedTxt != "") {
pageSelectedTxt="\n---\n"+pageSelectedTxt;
}
w.location.href="nvalt://make/?txt="+encodeURIComponent(tmplt+pageSelectedTxt)+"&title="+encodeURIComponent(pageTitle)+"&tags=bookmarks";
})();
/* Minified - use as bookmarklet */
javascript:(function(){var e=window,t=document,n=e.getSelection?e.getSelection():t.getSelection?t.getSelection():t.selection?t.selection.createRange().text:0,r=t.title,i=e.location.href,s="";s="Title: "+r+"\nLink: "+i+"\n";if(n!=""){n="\n---\n"+n}e.location.href="nvalt://make/?txt="+encodeURIComponent(s+n)+"&title="+encodeURIComponent(r)+"&tags=bookmarks"})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment