arXiv ar5iv Link

Add ar5iv link to arXiv page

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         arXiv ar5iv Link
// @namespace    https://github.com/sparanoid/userscript
// @supportURL   https://github.com/sparanoid/userscript/issues
// @version      0.1.0
// @description  Add ar5iv link to arXiv page
// @author       Sparanoid
// @license      AGPL
// @compatible   chrome 80 or later
// @compatible   edge 80 or later
// @compatible   firefox 74 or later
// @compatible   safari 13.1 or later
// @match        https://arxiv.org/*
// @icon         https://external-content.duckduckgo.com/ip3/arxiv.org.ico
// @grant        none
// ==/UserScript==

(function() {
  'use strict';
  const arxivUrl = document.querySelector('meta[property="og:url"]')?.getAttribute('content');
  const list = document.querySelector('#abs-outer > .extra-services > .full-text > ul');
  const li = document.createElement('li');
  const link = document.createElement('a');

  if (arxivUrl) {
    const ar5ivLink = arxivUrl.replace('arxiv', 'ar5iv');
    link.setAttribute('href', ar5ivLink);
    link.textContent = 'View in ar5iv';

    li.appendChild(link);
    list.appendChild(li);
  }
})();