// ==UserScript== // @icon https://github.githubassets.com/favicon.ico // @name Github 镜像访问,加速下载 // @namespace https://github.com/jadezi/github-accelerator/ // @version 1.1.5 // @description GitHub 镜像,github 加速 // @author jadezi // @license GPL License // @match *://github.com/* // @require https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js // @resource mycss https://gitee.com/jadezi/github-accelerator-css/raw/master/index.css // @grant GM_addStyle // @grant GM_setClipboard // @grant GM_getResourceText // @grant GM_getValue // @grant GM_setValue // @grant GM_registerMenuCommand // @grant GM_openInTab // @downloadURL none // ==/UserScript== (function() { var clone = true; // var clone = false; var depth = true; // var depth = false; var hide = true; var location = window.location.href; var mirror_url1 = "https://" + "github.com.cnpmjs.org"; var mirror_url2 = "https://" + "hub.fastgit.org"; var mirror_url3 = "https://" + "github.wuyanzheshui.workers.dev"; var download_url1 = "https://download.fastgit.org"; var str1 = ""; if (clone) { str1 += "git clone "; if (depth) { str1 += "--depth=1 "; } } var a = location.split("/"); var b = a[5] === "wiki" ? ".wiki" : ""; var str2 = "/" + a[3] + "/" + a[4] + b + ".git"; var clone_utl1 = str1 + mirror_url1 + str2; var clone_utl2 = str1 + mirror_url2 + str2; var str3 = window.location.pathname; var web_url1 = mirror_url1 + str3; var web_url2 = mirror_url2 + str3; var web_url3 = mirror_url3 + str3; // 镜像面板代码 var info = `
快速克隆1:
快速克隆2:
快速克隆3:
`; $(".repository-content").prepend(info); $(".Box.Box--condensed").each(function () { // 修改源代码下载栏样式 $(this).find(".d-block.py-1.py-md-2.Box-body.px-2").addClass("d-flex flex-justify-between") // 修改文件大小对齐方式 $(".pl-2.color-text-secondary.flex-shrink-0").css({"display":"flex","flex-grow":1,"justify-content":"flex-end"}) $(this).find(".d-flex.Box-body").each(function () { var href = $(this).children("a").attr("href"); var url1 = download_url1 + href; var url2 = mirror_url3 + href; var div1 = `
快速下载1
快速下载2(推荐)
` $(this).append(div1); }); }); // Fast download下载按钮 $(".dropdown-menu .list-style-none li:last").each(function () { var url1 = mirror_url3 +"/"+a[3]+"/"+a[4]+ "/archive/master.zip"; var span1 = `
  • Fast Download ZIP
  • `; $(this).after(span1); }); // 复制按钮 $("#button-copy1").on("click",function(){ GM_setClipboard($("#clone_case_1").val()) alert("复制成功") }) $("#button-copy2").on("click",function(){ GM_setClipboard($("#clone_case_2").val()) alert("复制成功") }) //页面跳转 $("#quickViewOne").on("click",function(){ window.location.href = web_url1 }); $("#quickViewOther").on("click",function(){ window.location.href = web_url2 }) $("#quickViewAnthor").on("click",function(){ window.location.href = web_url3 }) // 隐藏面板 $("#mirror-btn").on("click", function () { if (!hide) { $("#collapse").hide(); } else { $("#collapse").show(); } hide = !hide; }) function mirrorBtnEvent(){ if (!GM_getValue('mirror')) { $("#collapse").hide() }else{ $("#collapse").show(); } } function menuHideMirrorCollapse(){ GM_setValue('mirror',!GM_getValue('mirror')) mirrorBtnEvent() console.log(GM_getValue('mirror')) } function init(){ mirrorBtnEvent() } // 注册菜单 GM_registerMenuCommand(`【🔔隐藏 & 显示镜像信息面板】`,menuHideMirrorCollapse) GM_registerMenuCommand(`【📢意见 & 反馈】`,function () {window.GM_openInTab('https://github.com/jadezi/github-accelerator/issues/new', {active: true,insert: true,setParent: true});}) // 初始化面板 init() GM_addStyle(GM_getResourceText("mycss")); })();