Created
August 10, 2011 23:05
-
-
Save cmcbride/1138523 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 simple bookmarklet to make using NASA ADS simple at CfA | |
// (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 | |
var public_url = "adsabs.harvard.edu"; | |
var proxy_url = "adsabs.harvard.edu.ezp-prod1.hul.harvard.edu"; | |
// these shouldn't really use a string literal here, but just since | |
// above only really use '.' it should work | |
var re_pub = new RegExp(public_url) ; | |
var re_proxy = new RegExp(proxy_url); | |
var url = location.href; | |
if(url.match(re_proxy)!=null){ | |
url=url.replace(re_proxy,public_url); | |
location.href=url; | |
} | |
else if(url.match(re_pub)){ | |
url=url.replace(re_pub,proxy_url); | |
location.href=url; | |
} | |
else{ | |
alert("Current URL is not NASA ADS!\nDoes not match:\n" + location.protocol + "//" + public_url); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment