Arxiv HTML Viewer Redirect

Add a button to view HTML version of Arxiv papers

目前为 2025-01-31 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Arxiv HTML Viewer Redirect
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Add a button to view HTML version of Arxiv papers
  6. // @author Your Name
  7. // @match https://arxiv.org/abs/*
  8. // @match https://arxiv.org/pdf/*
  9. // @icon https://www.w3.org/html/logo/downloads/HTML5_Logo_256.png
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // Create a new button element
  17. const button = document.createElement('button');
  18. button.textContent = '查看HTML';
  19. button.style.position = 'fixed';
  20. button.style.top = '10px';
  21. button.style.right = '10px';
  22. button.style.zIndex = '1000';
  23. button.style.backgroundColor = '#4CAF50'; // Green
  24. button.style.color = 'white';
  25. button.style.border = 'none';
  26. button.style.padding = '10px 20px';
  27. button.style.textAlign = 'center';
  28. button.style.textDecoration = 'none';
  29. button.style.display = 'inline-block';
  30. button.style.fontSize = '16px';
  31. button.style.margin = '4px 2px';
  32. button.style.cursor = 'pointer';
  33. button.style.borderRadius = '12px';
  34.  
  35. // Get the current URL and extract the arXiv ID
  36. const url = window.location.href;
  37. const arxivIdMatch = url.match(/\/(abs|pdf)\/([0-9]+\.[0-9]+)/);
  38. if (arxivIdMatch) {
  39. const arxivId = arxivIdMatch[2];
  40.  
  41. // Add click event to the button
  42. button.onclick = () => {
  43. window.location.href = `https://ar5iv.labs.arxiv.org/html/${arxivId}`;
  44. };
  45.  
  46. // Append the button to the document body
  47. document.body.appendChild(button);
  48. }
  49. })();