// ==UserScript== // @icon https://github.githubassets.com/favicon.ico // @name GitHub镜像加速访问、克隆和下载 // @namespace RC1844.FastGithub // @author RC1844 // @homepageURL https://github.com/RC1844/FastGithub // @supportURL https://github.com/RC1844/FastGithub/issues // @license MIT License // @description 镜像访问GitHub、加速克隆和下载;适配Github新UI;增加新克隆站点;前往项目Github仓库查看免费搭建Github镜像站点方法 // @include *://github.com/* // @include *://github* // @include *://hub.fastgit.org/* // @require https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js // @version 1.5.3 // @run-at document-end // @grant GM_addStyle // @downloadURL none // ==/UserScript== (function () { //=true为启用,=false为禁用 var clone = true; // var clone = false; var depth = true; // var depth = false; var Setting = ""; if (clone) { Setting += "git clone "; if (depth) { Setting += "--depth=1 "; } } var MirrorUrl = new Array();//["Url", "Name", "Tip"] MirrorUrl[0] = ["https://github.com.cnpmjs.org", "Cnpmjs", ""]; MirrorUrl[1] = ["https://hub.fastgit.org", "Fastgit", ""]; MirrorUrl[2] = ["https://github.wuyanzheshui.workers.dev", "CF加速 1", "每日10万次调用上限"]; MirrorUrl[3] = ["https://github.bajins.com", "Bajins", "Bajins个人站点"]; MirrorUrl[4] = ["https://download.fastgit.org", "Fastgit", ""]; MirrorUrl[5] = ["https://github.rc1844.ml", "CF加速 2", MirrorUrl[2][2]]; MirrorUrl[6] = ["https://gitclone.com/github.com", "GitClone", ""]; MirrorUrl[7] = ["git@git.zhlh6.cn:", "加速你的Github", "利用ucloud提供的GlobalSSH"]; MirrorUrl[8] = ["https://github-speedup.laiczhang.com", "laiczhang", ""]; MirrorUrl[9] = ["https://cdn.jsdelivr.net/gh", "jsDelivr", "项目当前分支总文件大小不可超过 50MB"]; MirrorUrl[10] = ["https://g.ioiox.com/https://github.com", "Ioiox", "CN2 GIA 线路"]; MirrorUrl[11] = ["https://download.fastgit.org", "Fastgit", ""]; //添加对应索引即可使用 var CloneSet = [1, 8, 0, 6, 10]; var MirrorSet = [1, 8, 0, 3, 2, 5]; var DownloadSet = [4, 8, 2, 5, 10]; var RawSet = [11, 3, 2, 5]; //其他 var OtherUrl = new Array(); OtherUrl = [ ["https://github.com/RC1844/FastGithub", "脚本Github仓库地址,点个赞谢谢"], ["https://greasyfork.org/zh-CN/scripts/397419", "GreasyFork地址,希望可以给我评分收藏"], ["https://minhaskamal.github.io/DownGit", "DownGit"], ["https://gitclone.com", "GitClone"], ["https://d.serctl.com", "GitHub中转下载"], ["https://github.zhlh6.cn/", "加速你的Github"], ["http://gitd.cc", "GitHub代下服务"], ["https://gh.isteed.cc", "gh-proxy部署站点"], ["https://github.zsxwz.workers.dev", "gh-proxy部署站点"], ["https://gh.api.99988866.xyz", "gh-proxy部署站点"], ["https://gh.sky-and-poem.fun", "gh-proxy部署站点"], ]; var CloneList = addCloneList(); var OtherList = addOtherList(); addMenus(CloneList + addBrowseList() + OtherList); addReleasesList(); addDownloadZip(); addRawList(); $(document).on("pjax:success", function () { addMenus(CloneList + addBrowseList() + OtherList); addDownloadZip(); addReleasesList(); addRawList(); }); /** * 添加Raw列表 */ function addRawList() { $("#raw-url").each(function () { var href = $(this).attr("href"); RawSet.forEach((element) => { var span = $(this).clone().removeAttr("id"); span.attr({ href: MirrorUrl[element][0] + href, title: MirrorUrl[element][2], target: "_blank", }); span.text(MirrorUrl[element][1]); $(this).before(span); }); var span = $(this).clone().removeAttr("id"); span.attr({ href: MirrorUrl[9][0] + href.replace("/raw/", "@"), title: MirrorUrl[9][2], target: "_blank", }); span.text(MirrorUrl[9][1]); $(this).before(span); }); } /** * Fast Download ZIP */ function addDownloadZip() { $("a[data-open-app='link']").each(function () { var span = $(`
`); var href = $(this).attr("href"); var clone = $(this) .clone() .removeAttr("data-hydro-click data-hydro-click-hmac data-ga-click"); clone.addClass("Box-row Box-row--hover-gray"); DownloadSet.forEach((element) => { var span1 = clone.clone(); span1.attr({ href: MirrorUrl[element][0] + href, title: MirrorUrl[element][2], }); span1.html( span1.html().replace("Download ZIP", `Download ZIP(${MirrorUrl[element][1]})`) ); span = span.clone().append(span1); }); $(this).parent().after(span); }); } /** * 添加Releases列表 */ function addReleasesList() { $(".Box--condensed").each(function () { $(this) .find(".flex-items-center>a") .each(function () { var href = $(this).attr("href"); var span = ""; if (!IsPC()) { span = `