// ==UserScript== // @name Github Download // @namespace http://tampermonkey.net/ // @version 0.1 // @description 高速下载gihthub // @author Joye-bot // @license GPL-3.0 License // @match *://github.com/* // @match *://github* // @icon https://github.githubassets.com/favicon.ico // @grant none // @downloadURL none // ==/UserScript== (function () { 'use strict'; // Your code here... const cloneUrl = [ ["https://kgithub.com", "kGithub", "该公益加速源由 [kGithub] 提供 - 缓存: 无(时间很短)"], ["https://ghproxy.com/https://github.com", "ghproxy", "该公益加速源由 [ghproxy] 提供"], ["https://hub.njuu.cf", "njuu", "该公益加速源由 [LibraryCloud] 提供"], ["https://hub.yzuu.cf", "yzuu", "该公益加速源由 [LibraryCloud] 提供"], ]; const downloadUrl = [ // ["https://download.fastgit.org", "FastGit", "由KevinZonda推动的FastGit项目"], ["https://ghproxy.com/https://github.com", "ghproxy", "由 [ghproxy] 提供"], // ["https://gh.gh2233.ml/https://github.com", "gh2333", "由 [@X.I.U/XIU2] 提供"], // ["https://gh.ddlc.top/https://github.com", "ddlc", "由 [@mtr-static-official] 提供"] // ['https://gh2.yanqishui.work/https://github.com', 'yanqishui', '由 [@HongjieCN] 提供'], ['https://ghdl.feizhuqwq.cf/https://github.com', 'feizhuqwq', '由 [feizhuqwq.com] 提供'], ['https://gh-proxy-misakano7545.koyeb.app/https://github.com', 'koyeb', ''], ['https://gh.flyinbug.top/gh/https://github.com', 'flyinbug', '由 [Mintimate] 提供'], ]; const sshUrl = [ ["git@git.zhlh6.cn:", "zhlh6", "利用ucloud提供的GlobalSSH"], ]; const svg = [ '', '', '' ]; const style = [ 'padding:0 6px; margin-right: -1px; border-radius: 2px; background-color: var(--XIU2-back-Color); border-color: rgba(27, 31, 35, 0.1); font-size: 11px; color: var(--XIU2-font-Color);' ]; /** * 添加克隆列表 */ function addCloneList() { if (document.querySelector('.XIU2-GC')) return; let html = document.querySelector('[role="tabpanel"]:nth-child(2) div.input-group'); if (!html) return let href_split = html.getElementsByTagName('input')[0].getAttribute('value').split(location.host); let url = ''; let _html = ''; for (let i = 0; i < cloneUrl.length; i++) { url = cloneUrl[i][0] + href_split[1] _html += `
` + `` + `
` + `` + `${svg[1]}` + `` + `
` + `
`; } html.insertAdjacentHTML('afterend', _html); } /** * 添加ssh列表 */ function addSSHList() { if (document.querySelector('.XIU2-GCS')) return; let html = document.querySelector('[role="tabpanel"]:nth-child(3) div.input-group'); if (!html) return; let href_split = html.getElementsByTagName('input')[0].getAttribute('value').split(':'); let _html = ''; for (let i = 0; i < sshUrl.length; i++) { _html += `
` + ` ` + `
` + ` ` + `${svg[1]}` + ` ` + `
` + `
`; } html.insertAdjacentHTML('afterend', _html); } /** * 添加download zip */ function addDownloadZip() { if (document.querySelector('.XIU2-DZ')) return; let html = document.querySelectorAll('.Box-row.Box-row--hover-gray.p-3.mt-0')[1]; if (!html) return; let href = html.getElementsByTagName('a')[0].href; let url = ''; let _html = ''; for (let i = 0; i < downloadUrl.length; i++) { url = downloadUrl[i][0] + href.split(location.host)[1]; _html += `
  • ` + ` ` + `` + `Download` + `ZIP ${downloadUrl[i][1]}` + `` + `
  • `; } html.insertAdjacentHTML('afterend', _html); } /** * 添加Releases列表 */ function addReleasesList() { let html = document.querySelectorAll('.Box-footer'); let divDisplay = 'margin-left: -90px;'; if (document.documentElement.clientWidth > 755) { divDisplay = 'margin-top: -3px; margin-left: 15px; display: inherit;'; } for (const current of html) { if (current.querySelector('.XIU2-RS')) continue; current.querySelectorAll('li.Box-row a').forEach(function (_this) { let href = _this.href.split(location.host); let url = ''; let _html = `
    `; for (let i = 0; i < downloadUrl.length; i++) { url = downloadUrl[i][0] + href[1]; if (location.host !== "github.com") url = url.replace(location.host, "github.com"); _html += `${downloadUrl[i][1]}`; } _this.parentElement.nextElementSibling.insertAdjacentHTML('beforeend', _html + ''); } ); } } /** * 添加Tags列表 */ function addTagsList() { let html = document.querySelectorAll('.Box-row.position-relative.d-flex') let divDisplay = 'margin-left: -90px;'; if (document.documentElement.clientWidth > 755) { divDisplay = 'margin-top: -3px; margin-left: 15px; display: inherit;'; } for (const current of html) { let k = 0; if (current.querySelector('.XIU2-TS')) return; current.querySelectorAll('li.d-inline-block.mt-1.mr-2 a[rel="nofollow"]').forEach(function (_this) { let href = _this.href.split(location.host); let url = ''; let _html = `
    `; for (let i = 0; i < downloadUrl.length; i++) { url = downloadUrl[i][0] + href[1]; if (location.host !== "github.com") url = url.replace(location.host, "github.com"); _html += `${downloadUrl[i][1]}`; } if (k == 0) { _this.parentElement.nextElementSibling.insertAdjacentHTML('afterbegin', _html + ''); k++; } else { _this.parentElement.insertAdjacentHTML('beforeend', _html, '') } }); } } function run() { addCloneList(); addSSHList(); addDownloadZip(); if (location.pathname.split("/")[3] === "releases") { setTimeout(function () { addReleasesList(); }, 1000); } if (location.pathname.split("/")[3] === "tags") { addTagsList(); } } run(); })();