// ==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* // @include *://hub.fastgit.org/* // @require http://cdn.bootcss.com/jquery/1.8.3/jquery.min.js // @version 1.2.5 // @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://' + 'hub.fastgit.org'; mirror_url[2] = '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[2] + href; var url2 = 'https://download.fastgit.org' + href; var span1 = `
Fast Download ZIP1 Fast Download ZIP2
`; $('.get-repo-modal-options').after(span1); }); }); //Download Releases $('.release-main-section').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++) { var i=1; span += `快速下载${i} 快速下载${2}`; // } span += `
` $(this).after(span); }); }); $('.release-main-section').each(function () { $(this).find('.d-block.Box-body>a').each(function () { var href = $(this).attr('href'); var span = `快速下载1 快速下载2`; $(this).after(span); }); }); })();