Skip to content

Instantly share code, notes, and snippets.

@lmmx
Last active November 23, 2020 14:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lmmx/4dafda42f50514f2de9a to your computer and use it in GitHub Desktop.
Save lmmx/4dafda42f50514f2de9a to your computer and use it in GitHub Desktop.
Button to navigate to articles from Nature publications which are published before DOIs are assigned - clicking the bookmarklet uses Nature's search engine to find the correct article and navigates there (copy the text as a bookmark, the other file is there for reference)
javascript:(function(){if (window.location.href.indexOf('nature.com/doifinder/') > -1 && document.querySelector('span.largeParagraph > p').innerText.indexOf('DOI Handle') > -1) { doi = window.location.href.split('doifinder/')[1]; var naturexhr = new XMLHttpRequest(); naturexhr.open("GET","http://www.nature.com/search/executeSearch?sp-q="+doi.replace('/','%2F')+"&sp-p=all&pag-start=1&sp-c=25&sp-m=0&sp-s=&siteCode=default,true"); naturexhr.send(); naturexhr.onreadystatechange = function(){ if (naturexhr.readyState === 4 && naturexhr.status==200){ redirURL = naturexhr.response.match(/<h2 class="atl"><a href="(.*?)"/)[1]; window.location.href = redirURL; } } } else { alert('You need to be on the error page to do page redirect from the "invalid DOI" page'); }
})();
if (window.location.href.indexOf('http://www.nature.com/doifinder/') > -1 && document.querySelector('span.largeParagraph > p').innerText.indexOf('DOI Handle') > -1) {
doi = window.location.href.split('doifinder/')[1];
var naturexhr = new XMLHttpRequest();
naturexhr.open("GET","http://www.nature.com/search/executeSearch?sp-q="+doi.replace('/','%2F')+"&sp-p=all&pag-start=1&sp-c=25&sp-m=0&sp-s=&siteCode=default,true");
naturexhr.send();
naturexhr.onreadystatechange = function(){
if (naturexhr.readyState === 4 && naturexhr.status==200){
redirURL = naturexhr.response.match(/<h2 class="atl"><a href="(.*?)"/)[1];
window.location.href = redirURL;
}
}
}
else {
alert('You need to be on the error page to do page redirect from the "invalid DOI" page');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment