Last active
March 1, 2020 12:02
-
-
Save nishnik/2993db345b8fb3c2d1c18d766fba8f46 to your computer and use it in GitHub Desktop.
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
// ==UserScript== | |
// @name Change filename for arxiv downloads | |
// @namespace https://arxiv.org/ | |
// @version 1.0 | |
// @description Changes filename for the PDF link, so that once you open it in pdf js it downloads as "paper_name.pdf" instead of "year_month.identifier.pdf" | |
// @author Nishant Nikhil | |
// @match https://*.arxiv.org/abs/* | |
// @grant none | |
// ==/UserScript== | |
list_a = document.getElementsByTagName("a") | |
var link_pdf_a; | |
for (i = 0 ; i<list_a.length; i++) { | |
if (list_a[i].href.includes("pdf")) { | |
console.log(list_a[i].href); | |
link_pdf_a = list_a[i]; | |
} | |
} | |
list_h = document.getElementsByTagName("h1") | |
title_h = list_h[list_h.length - 1].innerText.replace(/ /g,"_"); | |
link_pdf_a.href = link_pdf_a.href + "&filename=" + title_h + '.pdf' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment