// ==UserScript== // @name Github 镜像访问,加速下载 // @icon https://github.githubassets.com/favicon.ico // @namespace https://github.com/jadezi/github-accelerator/ // @version 2.0.6 // @description GitHub 镜像,github 加速 // @author jadezi、wuyuehui // @license GPL License // @match *://github.com/* // @match *://hub.fastgit.xyz/* // @require https://cdn.bootcdn.net/ajax/libs/jquery/3.4.1/jquery.min.js // @resource customStyles 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 () { const clone_url_list = [ { name: '地址1', url: 'https://hub.fastgit.xyz', }, { name: '地址2', url: 'https://hub.0z.gs', }, { name: '地址3', url: 'https://api.mtr.pub', }, ] const download_url = [ 'https://mirror.ghproxy.com', 'https://gh-proxy.du33169.workers.dev', ] function init() { initMirrorUrl() isProjectUrl() setTimeout(addDownload, 2000); addRelease() } // Project页面不添加镜像面板 function isProjectUrl(){ const pathnameArr = window.location.pathname.split('/'); if(pathnameArr.length>3&&pathnameArr[3]=="projects"){ return }else{ addPanel() } } // 初始化镜像地址 function initMirrorUrl() { const _clone_url_list = clone_url_list.map(mirrorItem => { const [clone_url, quick_look_url] = joinCloneMirrorUrl(mirrorItem) return { clone_url, quick_look_url, } }) console.log('%c [ _clone_url_list ]', 'font-size:13px; background:pink; color:#bf2c9f;', _clone_url_list) GM_setValue('clone_url_list', _clone_url_list) } // 拼接克隆地址 const joinCloneMirrorUrl = (mirrorItem) => { const { url } = mirrorItem let commonUrl = '' commonUrl += "git clone "; commonUrl += url; const pathnameArr = window.location.pathname.split('/'); let clone_url = commonUrl + '/' + pathnameArr[1] + '/' + pathnameArr[2] + '.git' let quick_look_url = url + '/' + pathnameArr[1] + '/' + pathnameArr[2] return [clone_url, quick_look_url] } // 初始化镜像面板 function addPanel() { const clone_url_list = GM_getValue('clone_url_list') // 镜像面板模板 const mirror_template = `