GotoArXivMirrors

Open arXiv sites with arXiv mirrors

当前为 2019-08-06 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GotoArXivMirrors
  3. // @namespace https://github.com/zzilch/GotoArXivMirrors
  4. // @homepage https://github.com/zzilch/GotoArXivMirrors
  5. // @version 1.0
  6. // @author zzilch
  7. // @description Open arXiv sites with arXiv mirrors
  8. // @include /^https?://(.*\.)?arxiv\.org/.*/
  9. // @include http://xxx.itp.ac.cn/*
  10. // @run-at document-start
  11. // @grant GM_registerMenuCommand
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. let mirrors = {
  17. 'Main':'arxiv.org',
  18. 'China':'xxx.itp.ac.cn',
  19. 'Germany':'de.arxiv.org',
  20. 'India':'in.arxiv.org',
  21. }
  22. for(let mirror in mirrors){
  23. console.log(mirror+':'+location.href.replace(location.hostname,mirrors[mirror]).replace('https','http'))
  24. GM_registerMenuCommand(mirror, function(){
  25. location.replace(
  26. location.href.replace(location.hostname,mirrors[mirror])
  27. .replace('https','http'))
  28. });
  29. }
  30. })();
  31.  
  32.