// ==UserScript== // @icon https://github.githubassets.com/favicon.ico // @name GitHub 镜像加速下载 // @namespace https://github.com/RC1844 // @author RC1844 // @license MIT License // @description 加速GitHub克隆和下载 // @include *://github.com/* // @include *://github* // @require http://cdn.bootcss.com/jquery/1.8.3/jquery.min.js // @version 1.2.1 // @grant GM_addStyle // @downloadURL none // ==/UserScript== (function () { 'use strict'; //=true为启用,=false为禁用 var clone = true; // var clone = false; var depth = true; // var depth = false; var mirror_url = new Array(); mirror_url[0] = 'https://' + 'github.com.cnpmjs.org'; // mirror_url[1] = 'http://' + 'github-mirror.bugkiller.org'; mirror_url[1] = 'https://' + 'github.wuyanzheshui.workers.dev'; var str1 = ''; if (clone) { str1 += "git clone "; if (depth) { str1 += "--depth=1 "; } } var loca = window.location.href; var a = loca.split("/"); var str2 = '/' + a[3] + '/' + a[4] + '.git'; var str3 = window.location.pathname; var clone_url = new Array(); var web_url = new Array(); for (let i = 0; i < mirror_url.length; i++) { clone_url[i] = str1 + mirror_url[i] + str2; web_url[i] = mirror_url[i] + str3; } //镜像列表 var info = `
镜像网站
`; for (let i = 0; i < clone_url.length - 1; i++) { info += `
`; } info += `
`; for (let i = 0; i < web_url.length; i++) { info += `镜像浏览${i}`; } if (location.hostname != "github.com") { info += `返回GitHub` } info += `
`; $('.repository-content').prepend(info); //Fast Download ZIP $('.get-repo-modal-options').each(function () { $(this).find("a[rel='nofollow']").each(function () { var href = $(this).attr('href'); var url1 = mirror_url[1] + href; var span1 = `Fast Download ZIP`; $('.get-repo-modal-options').after(span1); }); }); //Download Releases $('.release-entry').each(function () { $(this).find('.d-flex.Box-body>a').each(function () { var href = $(this).attr('href'); var span = `
`; for (let i = 1; i < mirror_url.length; i++) { span += `快速下载${i}`; } span += `
` $(this).after(span); }); }); $('.release-entry').each(function () { $(this).find('.d-block.Box-body>a').each(function () { var href = $(this).attr('href'); var span = `快速下载`; $(this).after(span); }); }); })();