Links to academic papers in emails and on websites often point to the PDF of the paper. However, on sites like arXiv, I'd much rather be pointed to the HTML page. The index page is quick to load, and has meta-data not available in the PDF, such as the version history. I've given up trying to ask people not to deep-link to PDFs, and have instead written a browser extension to do what I want.
Install links: Firefox and Chrome
After installing this extension, links to PDFs on quite a few academic pages (listed below) redirect to an HTML index page, unless you clicked on the link from the main site.
- ACL Anthology: this pdf link redirects to this webpage
- ACM: this pdf link redirects to this webpage
- arXiv: this pdf link redirects to this webpage
- bioRxiv: this pdf link redirects to this webpage
- Citeseerx: this pdf link redirects to this webpage
- Indico: this pdf link redirects to this webpage
- JMLR: this pdf link redirects to this webpage
- JSTOR: this pdf link redirects to this webpage
- NeurIPS: this old-style pdf link redirects to this webpage. And this new-style pdf link redirects to this webpage.
- OpenReview: this pdf link redirects to this webpage
- PMLR: this pdf link redirects to this webpage
- Project Euclid: this pdf link redirects to this webpage. (Supporting URLs containing
Download?urlid=
turned out to be complicated. I may have to remove those rules if they cause too many issues.) - Research Gate: this pdf link redirects to this webpage
- Semantic Scholar: this pdf link redirects to this webpage
I gave the extension a fairly generic name. The redirect rules are stored in a list at the top of the code, and can easily be added to. However, making this list updatable within the extension is unlikely to happen soon, partly because of time, partly because allowing any URL to be redirected opens up security issues.
If you just want to use the extension as it is, get it from one of the official addon sites:
At the time of writing, it's possible but a bit of a pain to install on Firefox for Android (nightly).
-
arxiv-url-replacer a different Chrome extension for arXiv, with a GUI. Edits links in pages, instead of intercepting requests. A similar approach could be taken using TamperMonkey, which would immediately work in multiple browsers. It can be tricky to catch all links though.
-
Allen.YL Lee points out that a bookmarklet could be used to escape from a PDF after the fact, and provides an example.
And see the forks of this Github repo.
The code is written as a WebExtension, originally for Firefox, but it also works in Chrome too. As of 2021 it seems to work correctly in Chrome, whereas originally bugs in Chrome made the experience worse. The extension could probably be made to work in some other browsers, perhaps with some tweaking. But not by me.
If you want to add to the redirect rules, you currently have to edit the source code. To run the extension from the source:
-
Firefox: go to
about:debugging
and click "Load Temporary Add-on". Select either of the files in thesrc
directory. See Mozilla's WebExtensions documentation for more details. -
Chrome: go to
chrome://extensions
check developer mode, click load unpacked extension and select thesrc
directory. See Chrome's extension development getting started guide for more details. At the moment what I actually deploy is the version intmp_chrome_version
after running./package.sh
. At packaging time I remove handling of sites that don't work as intended in Chrome yet.
Pull requests providing new rules, fixes, or improvements are welcome, as are github issues (include example URLs demonstrating what you want). Although experience suggests I might take ages to look at them; sorry. If proposing code, please check both of the following in both Firefox and Chrome:
-
Requests for PDFs from external sites or the location bar are redirected.
-
Each redirect ends up at an HTML page with a link to the PDF, and clicking that link does give the PDF.
If you add support for a new site, please add an example PDF URL to test_cases
.
At some point in 2021, before Google lock things down, I should probably make a version of the extension that can use Chrome's new Manifest 3 API. It looks possible. As I use Firefox, I haven't got around to it yet.