Skip to content

Instantly share code, notes, and snippets.

@cmcbride
Created February 10, 2012 21:45
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 cmcbride/1793175 to your computer and use it in GitHub Desktop.
Save cmcbride/1793175 to your computer and use it in GitHub Desktop.
// this is a basic bookmarklet to simply CfA proxy use,
// especially with the NASA ADS system.
// (assuming one has a CfA PIN to log into the proxy)
//
// to make it a bookmarklet, run it through:
// John Gruber's Bookmarklet-Builder
// http://daringfireball.net/2007/03/javascript_bookmarklet_builder
// OR
// http://subsimple.com/bookmarklets/jsbuilder.htm
//
// Cameron McBride
// cmcbride@cfa
var author = "Cameron McBride";
var email = "cmcbride@cfa";
var last_edit = "10 Feb 2012";
var proxy_host = ".ezp-prod1.hul.harvard.edu";
var re_pub = /(adsabs.harvard.edu|iopscience.iop.org)/;
var re_proxy = new RegExp(proxy_host);
var url = location.href;
if(re_proxy.test(url)){
url=url.replace(re_proxy,"");
location.href=url;
}
else if(re_pub.test(url)){
/* add proxy */
url=url.replace(/\/([^\/]+)\//, "/$1" + proxy_host + "/");
location.href=url;
}
else{
alert("Current URL is not a known proxy!\nDoes not match:\n " + re_pub);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment