FastGithub 镜像加速访问、克隆和下载

镜像访问GitHub,极速Clone、Release/Raw/Zip加速;十几个站点可供选择;前往项目Github仓库查看免费搭建Github镜像站点方法

  1. // ==UserScript==
  2. // @icon https://github.githubassets.com/favicon.ico
  3. // @name FastGithub 镜像加速访问、克隆和下载
  4. // @namespace RC1844.FastGithub
  5. // @author RC1844
  6. // @homepageURL https://github.com/RC1844/FastGithub
  7. // @supportURL https://github.com/RC1844/FastGithub/issues
  8. // @license MIT License
  9. // @description 镜像访问GitHub,极速Clone、Release/Raw/Zip加速;十几个站点可供选择;前往项目Github仓库查看免费搭建Github镜像站点方法
  10. // @include *://github.com/*
  11. // @include *://github*
  12. // @include *://hub.fastgit.xyz/*
  13. // @require https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.slim.min.js
  14. // @version 1.6.6
  15. // ==/UserScript==
  16.  
  17. (function () {
  18. //=true为启用,=false为禁用
  19. var clone = true;
  20. // var clone = false;
  21. var depth = true;
  22. // var depth = false;
  23. var Setting = "";
  24. if (clone) {
  25. Setting += "git clone ";
  26. if (depth) {
  27. Setting += "--depth=1 ";
  28. }
  29. }
  30.  
  31. var MirrorUrl = new Array();//["Url", "Name", "Tip"]
  32. MirrorUrl[0] = ["https://github.com.cnpmjs.org", "Cnpmjs", "由cnpmjs.org提供"];
  33. MirrorUrl[1] = ["https://hub.fastgit.xyz", "FastGit", "由@KevinZonda推动的FastGit项目,请仔细甄别"];
  34. MirrorUrl[2] = ["https://github.wuyanzheshui.workers.dev", "CF加速 1", "每日10万次调用上限,由wuyanzheshui提供"];
  35. MirrorUrl[3] = ["https://github.bajins.com", "Bajins", "Bajins的个人站点"];
  36. MirrorUrl[4] = ["https://download.fastgit.org", "FastGit", MirrorUrl[1][2]];
  37. MirrorUrl[5] = ["https://github.rc1844.workers.dev", "CF加速 2", "每日10万次调用上限,由@RC1844提供"];
  38. MirrorUrl[6] = ["https://gitclone.com/github.com", "GitClone", "GitHub缓存加速网站,1元开会员尽享极速"];
  39. MirrorUrl[7] = ["git@git.zhlh6.cn:", "加速你的Github", "利用ucloud提供的GlobalSSH"];
  40. MirrorUrl[8] = ["https://github-speedup.laiczhang.com", "laiczhang", "laiczhang的个人站点"];
  41. MirrorUrl[9] = ["https://cdn.jsdelivr.net/gh", "jsDelivr", "项目当前分支总文件大小不可超过 50MB"];
  42. MirrorUrl[10] = ["https://ghproxy.com/https://github.com", "Ioiox", "CN2 GIA 线路"];
  43. MirrorUrl[11] = ["https://raw.fastgit.org", "FastGit", MirrorUrl[1][2]];
  44. MirrorUrl[12] = ["https://cdn.staticaly.com/gh", "Statically", "只能浏览图片和源代码文件,文件大小限制为30MB"]
  45. MirrorUrl[13] = ["git@ssh.fastgit.org", "FastGit", "MirrorUrl[1][2]"]
  46. // MirrorUrl[14] = ["https://iapk.cc/github?url=https://github.com", "IAPK", "IAPK工具箱·Github下载器"]
  47. // MirrorUrl[15] = ["https://gh.haval.gq", "CF加速 3", "每日10万次调用上限,由@Ecalose提供"]
  48. MirrorUrl[16] = ["https://cors.zme.ink/https://github.com", "netnr", "由@netnr提供"]
  49. //添加对应索引即可使用
  50. var CloneSet = [1, 13, 0, 6, 10];
  51. var MirrorSet = [1, 0, 3, 2, 5, 16];
  52. var DownloadSet = [4, 2, 5, 10];
  53. var RawSet = [3, 2, 5];
  54.  
  55. //其他
  56. var OtherUrl = new Array();
  57. OtherUrl = [
  58. ["https://github.com/RC1844/FastGithub", "脚本Github仓库地址,点个赞谢谢"],
  59. ["https://gf.qytechs.cn/zh-CN/scripts/397419", "GreasyFork地址,希望可以给我评分收藏"],
  60. ["https://doc.fastgit.org/", "FastGit,请仔细甄别"],
  61. ["https://minhaskamal.github.io/DownGit", "DownGit"],
  62. ["https://zhoudaxiaa.gitee.io", "DownGit 周大侠啊"],
  63. ["https://gitclone.com", "GitClone,1元开会员"],
  64. ["https://d.serctl.com", "GitHub中转下载"],
  65. ["https://gitee.com/organizations/mirrors/projects", "Gitee 极速下载"],
  66. ["https://codechina.csdn.net/mirrors", "CSDN Mirrors 镜像仓库"],
  67. ["https://toolwa.com", "孟坤工具箱"],
  68. ["https://github.zhlh6.cn/", "加速你的Github"],
  69. ["http://gitd.cc", "GitHub代下服务"],
  70. ["https://gh.isteed.cc", "gh-proxy部署站点1"],
  71. ["https://github.zsxwz.workers.dev", "gh-proxy部署站点2"],
  72. ["https://gh.api.99988866.xyz", "gh-proxy部署站点3"],
  73. ["https://gh.sky-and-poem.fun", "gh-proxy部署站点4"],
  74. ["https://github.b15.me", "gh-proxy部署站点5"],
  75. ["https://github.xxyyzz.workers.dev", "gh-proxy部署站点6"],
  76. ["https://gh.argv.cc", "gh-proxy部署站点6"],
  77. ];
  78. var CloneList = addCloneList();
  79. var OtherList = addOtherList();
  80. var isPC = IsPC();
  81.  
  82. function callback(_mutationList, _observer) {
  83. setTimeout(run, 1500);
  84. }
  85. const observer = new MutationObserver(callback);
  86. observer.observe(document.querySelector("head"), { attributes: true, childList: true });
  87.  
  88. var pathname;
  89. function run() {
  90. if (location.pathname != pathname) {
  91. pathname = location.pathname;
  92. $("#mirror-menu").remove();
  93. addMenus(CloneList + addBrowseList() + OtherList);
  94. if (location.pathname.split("/")[3] == "releases")
  95. addReleasesList();
  96. if (isPC)
  97. addDownloadZip();
  98. addRawList();
  99. }
  100. }
  101. run();
  102. /**
  103. * 添加Raw列表
  104. */
  105. function addRawList() {
  106. $("#raw-url").each(function () {
  107. var href = $(this).attr("href");
  108. rawHtml(11, MirrorUrl[11][0] + href.replace("/raw", ""));
  109. RawSet.forEach((element) => {
  110. rawHtml(element, MirrorUrl[element][0] + href);
  111. });
  112. rawHtml(9, MirrorUrl[9][0] + href.replace("/raw/", "@"));
  113. rawHtml(12, MirrorUrl[12][0] + href.replace("/raw", ""));
  114.  
  115. function rawHtml(element, Url) {
  116. var span = $("#raw-url").clone().removeAttr("id");
  117. span.attr({
  118. href: Url,
  119. title: MirrorUrl[element][2],
  120. target: "_blank",
  121. });
  122. span.text(MirrorUrl[element][1]);
  123. $("#raw-url").before(span);
  124. }
  125. });
  126. }
  127.  
  128. /**
  129. * Fast Download ZIP
  130. */
  131. function addDownloadZip() {
  132. $("a[data-open-app='link']").each(function () {
  133. var span = $(`<li class="Box-row p-0"></li>`);
  134. var href = $(this).attr("href");
  135. var clone = $(this)
  136. .clone()
  137. .removeAttr("data-hydro-click data-hydro-click-hmac data-ga-click");
  138. clone.addClass("Box-row Box-row--hover-gray");
  139. DownloadSet.forEach((element) => {
  140. var span1 = clone.clone();
  141. span1.attr({
  142. href: MirrorUrl[element][0] + href,
  143. title: MirrorUrl[element][2],
  144. });
  145. span1.html(
  146. span1.html().replace("Download ZIP", `Download ZIP(${MirrorUrl[element][1]})`)
  147. );
  148. span.append(span1);
  149. });
  150. $(this).parent().after(span);
  151. });
  152. }
  153. /**
  154. * 添加Releases列表
  155. */
  156. function addReleasesList() {
  157. $(".Box--condensed").find("[href]").each(function () {
  158. var href = $(this).attr("href");
  159. $(this).parent().after(`<div class="d-flex">` + downloadHref(href) + `</div>`);
  160. $(this).parent().removeClass("Box-body");
  161.  
  162. function downloadHref(href) {
  163. var span = "";
  164. DownloadSet.forEach((element) => {
  165. span += `<a class="flex-1 btn btn-outline get-repo-btn BtnGroup-item"
  166. style="float: none; border-color: var(--color-btn-outline-text);"
  167. rel="nofollow"
  168. href="${MirrorUrl[element][0] + href}"
  169. title="${MirrorUrl[element][2]}">${MirrorUrl[element][1]}</a>`;
  170. });
  171. return span;
  172. }
  173. });
  174. }
  175. /**
  176. * 检测是否为PC端
  177. */
  178. function IsPC() {
  179. var userAgentInfo = navigator.userAgent;
  180. var Agents = [
  181. "Android",
  182. "iPhone",
  183. "SymbianOS",
  184. "Windows Phone",
  185. "iPad",
  186. "iPod",
  187. ];
  188. var flag = true;
  189. const len = Agents.length;
  190. for (var v = 0; v < len; v++) {
  191. if (userAgentInfo.indexOf(Agents[v]) > 0) {
  192. flag = false;
  193. break;
  194. }
  195. }
  196. return flag;
  197. }
  198. /**
  199. * 添加菜单列表
  200. */
  201. function addMenus(info) {
  202. if (isPC)
  203. $("#repository-details-container > ul.pagehead-actions").prepend(`<li>${info}</li>`);
  204. else
  205. $("span.Label.Label--secondary.v-align-middle.mr-1").after(`<span>${info}</span>`);
  206. }
  207. /**
  208. * 添加克隆列表
  209. */
  210. function addCloneList() {
  211. var href = window.location.href.split("/");
  212. var git = href[3] + "/" + href[4] + ".git";
  213. var info = `<details class="details-reset details-overlay mr-0 mb-0" id="mirror-menu">
  214. <summary class="btn btn-sm ml-2 btn-primary" data-hotkey="m" title="打开列表" aria-haspopup="menu" role="button">
  215. <span class="css-truncate-target" data-menu-button="">克隆与镜像</span>
  216. <span class="dropdown-caret"></span>
  217. </summary>
  218.  
  219. <details-menu class="SelectMenu SelectMenu--hasFilter" role="menu">
  220. <div class="SelectMenu-modal" style="width: 400px;">
  221.  
  222. <header class="SelectMenu-header">
  223. <span class="SelectMenu-title">镜像站点与快速克隆</span>
  224. <button class="SelectMenu-closeButton" type="button" data-toggle-for="mirror-menu"><svg aria-label="Close menu"
  225. class="octicon octicon-x" width="16" height="16" role="img">
  226. <path fill-rule="evenodd"
  227. d="M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z">
  228. </path>
  229. </svg></button>
  230. </header>
  231.  
  232. <tab-container class="d-flex flex-column js-branches-tags-tabs" style="min-height: 0;">
  233.  
  234. <div class="SelectMenu-tabs" role="tablist">
  235. <button class="SelectMenu-tab" type="button" role="tab"
  236. aria-selected="true" tabindex="0">主要</button>
  237. <button class="SelectMenu-tab" type="button" role="tab"
  238. aria-selected="false" tabindex="-1">其他</button>
  239. </div>
  240.  
  241. <div role="tabpanel" class="flex-column flex-auto overflow-auto" tabindex="0">
  242. <div class="SelectMenu-list" data-filter-list="">
  243. <div class="btn-block"
  244. style="padding: 4px;background-color: #ffffdd;color: #996600;" role="alert">
  245. clonedepth命令的插入可手动编辑代码关闭</div>
  246. <div class="btn-block flash-error"
  247. style="padding: 4px;color: #990000;" role="alert">
  248. 请不要在镜像网站登录(不可用)账号,若因此造成任何损失本人概不负责</div> `;
  249. //克隆列表
  250. CloneSet.forEach((element) => {
  251. info += cloneHtml(Setting + MirrorUrl[element][0] + "/" + git, MirrorUrl[element][1]);
  252. });
  253. info += cloneHtml(Setting + MirrorUrl[7][0] + git, MirrorUrl[7][1]);
  254. info += cloneHtml("git remote set-url origin https://github.com/" + git, "还原GitHub仓库地址");
  255. function cloneHtml(Url, Tip) {
  256. return `<div class="input-group notranslate" title="${Tip}">
  257. <input type="text" class="form-control input-monospace input-sm color-bg-subtle" data-autoselect=""
  258. value="${Url}" aria-label="${Url}"
  259. readonly="">
  260. <div class="input-group-button">
  261. <clipboard-copy value="${Url}" aria-label="Copy to clipboard"
  262. class="btn btn-sm js-clipboard-copy tooltipped-no-delay ClipboardButton js-clone-url-http"
  263. data-copy-feedback="Copied!" data-tooltip-direction="n" role="button"><svg aria-hidden="true" height="16"
  264. viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true"
  265. class="octicon octicon-copy js-clipboard-copy-icon d-inline-block">
  266. <path
  267. d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z">
  268. </path>
  269. <path
  270. d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z">
  271. </path>
  272. </svg><svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16"
  273. data-view-component="true"
  274. class="octicon octicon-check js-clipboard-check-icon color-fg-success d-inline-block d-sm-none">
  275. <path
  276. d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z">
  277. </path>
  278. </svg></clipboard-copy>
  279. </div>
  280. </div>`;
  281. }
  282. return info;
  283. }
  284.  
  285.  
  286. /**
  287. * 添加镜像浏览列表
  288. */
  289. function addBrowseList() {
  290. var info = ``;
  291. var href = window.location.href.split("/");
  292. var path = window.location.pathname;
  293. MirrorSet.forEach((element) => {
  294. info += listHtml(MirrorUrl[element][0] + path, `镜像浏览(${MirrorUrl[element][1]})`, MirrorUrl[element][2]);
  295. });
  296. if (
  297. href.length == 5 ||
  298. path.includes("/tree/") ||
  299. path.includes("/blob/")
  300. ) {
  301. var Html =
  302. MirrorUrl[9][0] + path.replace("/tree/", "@").replace("/blob/", "@");
  303. if (!path.includes("/blob/")) {
  304. Html += "/";
  305. }
  306. info += listHtml(Html, `镜像浏览(${MirrorUrl[9][1]})`, MirrorUrl[9][2]);
  307. }
  308. if (location.hostname != "github.com") {
  309. info += listHtml(`https://github.com${path}`, "返回GitHub");
  310. }
  311. return info;
  312. }
  313.  
  314. /**
  315. * 添加其他列表
  316. */
  317. function addOtherList() {
  318. var info = `
  319. </div>
  320. </div>
  321. <div role="tabpanel" class="flex-column flex-auto overflow-auto"
  322. tabindex="0" hidden="">
  323. <div class="SelectMenu-list">
  324. `;
  325. //其他列表
  326. OtherUrl.forEach((element) => {
  327. info += listHtml(element[0], element[1]);
  328. });
  329. info += `</div>
  330. </div>
  331. </tab-container>
  332. </div>
  333. </details-menu>
  334. </details>`;
  335. return info;
  336. }
  337. function listHtml(Url, Name, Tip = "") {
  338. return `<a class="SelectMenu-item"
  339. href="${Url}" target="_blank"
  340. title="${Tip}" role="menuitemradio"
  341. aria-checked="false" rel="nofollow">
  342. <span class="css-truncate css-truncate-overflow"
  343. style="text-align:center;">
  344. ${Name}
  345. </span>
  346. </a>`;
  347. }
  348. })();

QingJ © 2025

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