1

At some point (I think quite recently, but I'm not sure), Nature started forcing the browser to download the PDF files for papers, instead of opening them in the browser. How can I force the browser to stop this behaviour, and open PDF links in the browser?

E.P.
  • 219

1 Answers1

1

There are apparently several ways in which the website can try to force your web browser to download a given file instead of opening it in-window. One way in which this can happen (sending the attribute Content-Disposition: attachment instead of inline in the http header of the response) has already been handled in this thread.

What Nature is currently doing is including a download attribute in the a link tag that goes to the pdf. This can be diagnosed (in Google Chrome) by right-clicking the link and looking at the tag itself in the element viewer:

This can be fixed by using a suitable userscript to remove this attribute using a userscript manager like Tampermonkey for Google Chrome or GreaseMonkey for Firefox.

This is a simple userscript that will do it:

// ==UserScript==
// @name     View Nature pdfs in-browser
// @include  https://www.nature.com/*
// @require  http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js
// ==/UserScript==

/--- Use the jQuery contains selector to find content to remove. Beware that not all whitespace is as it appears. /

var allLinks, thisLink; allLinks = document.evaluate( '//a[@download]', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); for (var i = 0; i < allLinks.snapshotLength; i++) { thisLink = allLinks.snapshotItem(i); thisLink.removeAttribute('download'); }

E.P.
  • 219