Skip to content

Instantly share code, notes, and snippets.

@corydolphin
Last active December 12, 2015 00:28
Show Gist options
  • Save corydolphin/4684224 to your computer and use it in GitHub Desktop.
Save corydolphin/4684224 to your computer and use it in GitHub Desktop.
Reading textbooks on nature.com sucks. They try and force you to open everything in the same window and every link invokes a JS function. This Gist contains the JS I use in a userscript to improve the readability, and can be found in the chrome store: https://chrome.google.com/webstore/detail/naturecom-readability-imr/caehidepagpmhcgajebpggaldjl…
var myFun = function(){
for(var nl = document.querySelectorAll(".nlsInlineLinksGrey.expand"), i=0; i < nl.length; i++){
nl[i].click();
};
for(var nl = document.querySelectorAll(".nlsInlineLinks.toWrapLongWord"), i=0; i < nl.length; i++){
nl[i].href = "http://www.nature.com/principles/ebooks/sci1210-principles-of-modern-biology-15577452/" + nl[i].href.replace(/[^\d]/g, "");
};
window.addEventListener("keydown", function(event) {
if (!event){event = window.event;}
var code = event.keyCode;
if (event.charCode && code == 0){
code = event.charCode;
}
if(code === 39){
document.querySelector(".bookArticleNext").click()
}
else if(code === 37){
document.querySelector(".bookArticlePrev").click()
}
});
console.log("Nature.com fixer Running");
};
location.href = 'javascript:((' + myFun.toString() + ')())'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment