Skip to content

Instantly share code, notes, and snippets.

@nishnik
Last active March 1, 2020 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nishnik/2993db345b8fb3c2d1c18d766fba8f46 to your computer and use it in GitHub Desktop.
Save nishnik/2993db345b8fb3c2d1c18d766fba8f46 to your computer and use it in GitHub Desktop.
// ==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