🏠 Home 

ArxivRedirector

An Arxiv Redirector for ##### Mainland


Install this script?
  1. // ==UserScript==
  2. // @name ArxivRedirector
  3. // @namespace https://github.com/tao-shen/ArxivRedirector
  4. // @homepage https://github.com/tao-shen/ArxivRedirector
  5. // @version 1.2
  6. // @author tao.shen
  7. // @description An Arxiv Redirector for ##### Mainland
  8. // @include /^https?://(.*\.)?arxiv\.org/.*/
  9. // @include http://xxx.itp.ac.cn/*
  10. // @run-at document-start
  11. // ==/UserScript==
  12. window.onload=function() {
  13. 'use strict';
  14. if (location.href.search('xxx.itp.ac.cn') == -1){
  15. function incompletePDF(url){ return url.includes('/pdf') && !url.endsWith('pdf') }
  16. function abstractURL(url){ return url.includes('/abs') }
  17. let mirrors = {
  18. '#####':'xxx.itp.ac.cn',
  19. }
  20. let mirror='#####'
  21. let url = location.href.replace(location.hostname,mirrors[mirror]).replace('https','http')
  22. url = incompletePDF(url) ? url+'.pdf' : url
  23. console.log(mirror+':'+url)
  24. location.replace(url,'xxx.itp.ac.cn')}
  25. }