Arxiv PDF 一键下载并重命名

一键下载 Arxiv 上的 pdf 文件,并以清晰的命名格式重命名文件

  1. // ==UserScript==
  2. // @name Arxiv PDF Rename & Download
  3. // @name:zh-CN Arxiv PDF 一键下载并重命名
  4. // @namespace http://tampermonkey.net/
  5. // @version 1.0
  6. // @description This script will generate a download buttom at the right-bottom of the website which download the pdf paper with a clear name.
  7. // @description:zh-CN 一键下载 Arxiv 上的 pdf 文件,并以清晰的命名格式重命名文件
  8. // @author Omen
  9. // @license GPLv3
  10. // @match https://arxiv.org/abs/*
  11. // @grant none
  12. // @icon https://arxiv.org/static/browse/0.3.4/images/icons/favicon-32x32.png
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. const pageTitle = document.title;
  19.  
  20. const illegalChars = /[\/\\:*?"<>|]/g;
  21. const cleanTitle = pageTitle.replace(illegalChars, ' ');
  22.  
  23. const downloadButton = document.createElement('button');
  24. downloadButton.textContent = 'Download';
  25. downloadButton.style.position = 'fixed';
  26. downloadButton.style.bottom = '10px';
  27. downloadButton.style.right = '10px';
  28. downloadButton.style.backgroundColor = 'red';
  29. downloadButton.style.color = 'white';
  30. downloadButton.style.border = 'none';
  31. downloadButton.style.padding = '10px 20px';
  32. downloadButton.style.cursor = 'pointer';
  33. downloadButton.style.zIndex = '1000';
  34. downloadButton.style.borderRadius = '5px';
  35. downloadButton.style.boxShadow = '0 4px 8px rgba(0, 0, 0, 0.2)';
  36.  
  37. downloadButton.addEventListener('click', () => {
  38. const pdfUrl = window.location.href.replace('/abs/', '/pdf/');
  39. downloadButton.textContent = 'Downloading...';
  40. downloadButton.disabled = true;
  41. downloadButton.style.backgroundColor = '#C62828';
  42. fetch(pdfUrl)
  43. .then(response => response.blob())
  44. .then(blob => {
  45. const url = window.URL.createObjectURL(blob);
  46. const a = document.createElement('a');
  47. a.href = url;
  48. a.download = `${cleanTitle}.pdf`;
  49. document.body.appendChild(a);
  50. a.click();
  51. a.remove();
  52. window.URL.revokeObjectURL(url);
  53. downloadButton.textContent = 'Done';
  54. downloadButton.disabled = false;
  55. downloadButton.style.backgroundColor = '#E53935';
  56. }).catch(error => {
  57. downloadButton.textContent = 'There has been a problem with fetch operation:'+ error;
  58. downloadButton.disabled = false;
  59. });
  60. });
  61.  
  62. document.body.appendChild(downloadButton);
  63. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址