maven2aliyun

替换maven中的下载地址为阿里云的地址

目前为 2023-08-15 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name maven2aliyun
  3. // @namespace maven2aliyun
  4. // @version 0.1
  5. // @description 替换maven中的下载地址为阿里云的地址
  6. // @document
  7. // @author icefairy
  8. // @match *://repo1.maven.org/*
  9. // @run-at document-idle
  10. // @require https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js
  11. // @grant none
  12. // @license MIT
  13. // ==/UserScript==
  14. (() => {
  15. $("a").each((index, e) => {
  16. const jElement = $(e);
  17. const title = jElement.attr("title");
  18. if (!title) {
  19. return;
  20. }
  21. let newurl=e.href;
  22. if(newurl.indexOf(".jar")>-1 || newurl.indexOf(".pom")>-1){
  23. newurl=newurl.replace('repo1.maven.org/maven2','maven.aliyun.com/nexus/content/repositories/central');
  24. }
  25. jElement.attr("href",newurl);
  26. });
  27. })();
  28.