Skip to content

Instantly share code, notes, and snippets.

@jiffyclub
Created October 17, 2012 00:56
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save jiffyclub/3903134 to your computer and use it in GitHub Desktop.
Save jiffyclub/3903134 to your computer and use it in GitHub Desktop.
A bookmarklet that tries to open the current page in nbviewer. White space has been trimmed for brevity. To use make a new bookmark and copy the code below into the URL field.
javascript:date=new Date();
url_root='http://nbviewer.ipython.org/';
url=null;
if (location.href.search(/^https?:\/\/gist\.github\.com\/[0-9]+$/) !== -1) {
gist = location.href.match(/^https?:\/\/gist\.github\.com\/([0-9]+)$/);
url = url_root + gist[1];
} else if (location.href.search(/^https:\/\/.*\.ipynb$/) !== -1) {
path = location.href.match(/^https:\/\/(.*\.ipynb)$/);
url = url_root + 'urls/' + path[1];
} else if (location.href.search(/^http:\/\/.*\.ipynb$/) !== -1) {
path = location.href.match(/^http:\/\/(.*\.ipynb)$/);
url = url_root + 'url/' + path[1];}
if (url) {
void(window.open(url, 'nbviewer' + date.getTime()));}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment