Created
February 10, 2012 21:45
-
-
Save cmcbride/1793175 to your computer and use it in GitHub Desktop.
This file contains 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
// 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