ArxivRedirector

An Arxiv Redirector for China Mainland

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل 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')}
}