ArxivRedirector

An Arxiv Redirector for China Mainland

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         ArxivRedirector
// @namespace    https://github.com/tao-shen/ArxivRedirector
// @homepage     https://github.com/tao-shen/ArxivRedirector
// @version      1.2
// @author       tao.shen
// @description  An Arxiv Redirector for China Mainland
// @include      /^https?://(.*\.)?arxiv\.org/.*/
// @include      http://xxx.itp.ac.cn/*
// @run-at       document-start
// ==/UserScript==

window.onload=function() {
    'use strict';
    if (location.href.search('xxx.itp.ac.cn') == -1){
    function incompletePDF(url){ return url.includes('/pdf') && !url.endsWith('pdf') }
    function abstractURL(url){ return url.includes('/abs') }
    let mirrors = {
        'China':'xxx.itp.ac.cn',
    }
    let mirror='China'
    let url = location.href.replace(location.hostname,mirrors[mirror]).replace('https','http')
    url = incompletePDF(url) ? url+'.pdf' : url
    console.log(mirror+':'+url)
    location.replace(url,'xxx.itp.ac.cn')}
}