FastGit

GitHub Clone or download、releases 下载加速

当前为 2020-06-28 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name FastGit
  3. // @version 0.5
  4. // @description GitHub Clone or download、releases 下载加速
  5. // @author Vhxubo
  6. // @license MIT
  7. // @icon https://github.githubassets.com/favicon.ico
  8. // @homepage https://gist.github.com/vhxubo/d67fbd5bb3b7308b2e3690ca58e12c12
  9. // @namespace https://gist.github.com/vhxubo/d67fbd5bb3b7308b2e3690ca58e12c12
  10. // @match https://github.com/*/*
  11. // @grant none
  12. // @note 2020.06.27_V0.5 适配新版 UI
  13. // @note 2020.05.06_V0.4 新增: zipProxy - zip 下载链接
  14. // ==/UserScript==
  15.  
  16. (function () {
  17. 'use strict';
  18. var gitProxy = 'https://hub.fastgit.org';
  19. var sshProxy = 'git@fastgit.org';
  20. var releaseProxy = 'https://release.fastgit.org';
  21. var zipProxy = 'https://download.fastgit.org';
  22.  
  23. if (window.location.href.indexOf('releases') === -1) {
  24. var regex = /"((\/.*)+\.zip)"/;
  25. var domDownload = document.querySelector('span.d-flex')||document.querySelector('get-repo-controller');
  26. if (domDownload !== null) {
  27. var oldHtml = domDownload.outerHTML;
  28. var zipLink = gitProxy + regex.exec(oldHtml)[1];
  29. var outHtml = oldHtml
  30. .replace('Clone or download', 'FastGit')
  31. .replace('Clone', 'FastGit')
  32. .replace(/https:\/\/github.com/g, gitProxy)
  33. .replace(regex, zipLink)
  34. .replace(/git@github.com/g, sshProxy)
  35. .replace('https%3A%2F%2Fgithub.com', 'https%3A%2F%2Fhub.fastgit.org');
  36.  
  37. domDownload.insertAdjacentHTML('afterend', outHtml);
  38. }
  39. } else {
  40. var resDownload = document.querySelectorAll('.Box--condensed a');
  41. if (resDownload !== null) {
  42. var i;
  43. for (i = 0; i < resDownload.length; i++) {
  44. var resHref = resDownload[i].getAttribute('href');
  45. if(resHref.indexOf('.zip') === -1) {
  46. resDownload[i].insertAdjacentHTML(
  47. 'afterend',
  48. `<a style="cursor: pointer;" href="${
  49. releaseProxy + resHref
  50. }">FastGit Download</a>`
  51. );
  52.  
  53. } else {
  54. resDownload[i].insertAdjacentHTML(
  55. 'afterend',
  56. `<a style="cursor: pointer;" href="${
  57. zipProxy + resHref
  58. }">FastGit Download</a>`
  59. );
  60. }
  61. }
  62. }
  63. }
  64. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址