Last active
August 29, 2015 14:05
-
-
Save aaronwolen/ab7288f40ada1fbdadf9 to your computer and use it in GitHub Desktop.
Bookmarklet to automatically insert proxy stems for accessing journal articles off-campus.
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
javascript:var%20insert_proxy%20=%20function(proxy)%20{var%20url%20=%20document.URL;if%20(url.indexOf(proxy)%20===%20-1)%20{var%20parser%20=%20document.createElement(%27a%27);parser.href%20=%20url;var%20host%20=%20parser.host;if%20(host%20==%20%27www.ncbi.nlm.nih.gov%27)%20{host%20=%20host.replace(/\./g,%20%27-%27);};host%20=%20host.concat(proxy);proxy_url%20=%20url.replace(parser.host,%20host);window.open(proxy_url,%20%27_self%27);};};insert_proxy(%27.proxy.library.vcu.edu%27); |
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
var insert_proxy = function(proxy) { | |
var url = document.URL; | |
// Check if URL already contains proxy | |
if (url.indexOf(proxy) === -1) { | |
var parser = document.createElement('a'); | |
parser.href = url; | |
var host = parser.host; | |
// PubMed requires dashes (for some reason) | |
if (host == 'www.ncbi.nlm.nih.gov') { | |
host = host.replace(/\./g, '-'); | |
}; | |
host = host.concat(proxy); | |
proxy_url = url.replace(parser.host, host); | |
window.open(proxy_url, '_self'); | |
}; | |
}; | |
insert_proxy('.proxy.library.vcu.edu'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment