Skip to content

Commit 1913fe9

Browse files
committed
新增 [Git Clone SSH] 加速(中国北京、中国香港); 新增 [美国洛杉矶] Release 加速源
1 parent 35d115f commit 1913fe9

1 file changed

Lines changed: 76 additions & 40 deletions

File tree

GithubEnhanced-High-Speed-Download.user.js

Lines changed: 76 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name Github 增强 - 高速下载
3-
// @version 1.4.8
3+
// @version 1.4.9
44
// @author X.I.U
55
// @description 高速下载 Git Clone、Release、Raw、Code(ZIP) 等文件、项目列表单文件快捷下载 (☁)
66
// @match *://github.com/*
@@ -29,20 +29,25 @@
2929
fontColor = '#b2b8bf';
3030
}
3131
}
32-
32+
//['https://github.91chifun.workers.dev','美国'],
3333
var download_url = [
3434
['https://gh.api.99988866.xyz','美国'],
35-
['https://github.91chifun.workers.dev','美国'],
35+
['https://gh.msx.workers.dev','美国'],
3636
['https://gh.xiu2.xyz','美国'],
37+
['https://git.yumenaka.net','美国洛杉矶'],
3738
['https://download.fastgit.org','日本东京'],
3839
['https://ghproxy.com','韩国首尔'],
3940
['https://pd.zwc365.com/seturl','中国香港']
4041
],
4142
clone_url = [
4243
['https://hub.fastgit.org','中国香港'],
43-
['https://gitclone.com','中国浙江杭州'],
44+
['https://gitclone.com','中国浙江'],
4445
['https://ghp.lvmhsh.cn.cnpmjs.org','新加坡']
4546
],
47+
clone_ssh_url = [
48+
['git@git.zhlh6.cn','中国北京'],
49+
['git@hub.fastgit.org','中国香港']
50+
],
4651
raw_url = [
4752
['https://raw.githubusercontent.com','Github 原生',''],
4853
['https://cdn.jsdelivr.net','中国国内','注意:该加速源存在缓存机制(24小时),所以文件可能不是最新。
注意:当前分支所有文件总文件大小超过 50MB 时,该加速源不可用。
注意:当前分支名为版本号格式时(如 v1.2.3),该高速下载链接因格式限制不可用。'],
@@ -89,16 +94,18 @@
8994
};
9095

9196
addRelease(); // Release 加速
92-
addDownloadZIP(); // Source Code 加速
93-
addGitClone(); // Download ZIP/Code(ZIP) 加速
97+
addDownloadZIP(); // Download ZIP 加速
98+
addGitClone(); // Git Clone 加速
99+
addGitCloneSSH(); // Git Clone SSH 加速
94100
addRawFile(); // Raw 加速
95101
setTimeout(addRawDownLink, 2000); // 添加 Raw 下载链接(☁),延迟 2 秒执行,避免被 pjax 刷掉
96102

97103
document.addEventListener('pjax:success',function(){ // pjax 事件发生后
98104
addRelease(); // Release 加速
99-
addDownloadZIP(); // Source Code 加速
100-
addGitClone(); // Download ZIP/Code(ZIP) 加速
101-
addRawFile(); // 添加 Raw 加速按钮
105+
addDownloadZIP(); // Download ZIP 加速
106+
addGitClone(); // Git Clone 加速
107+
addGitCloneSSH(); // Git Clone SSH 加速
108+
addRawFile(); // Raw 加速
102109
setTimeout(addRawDownLink, 2000); // 添加 Raw 下载链接(☁),延迟 2 秒执行,避免被 pjax 刷掉
103110
});
104111

@@ -118,15 +125,17 @@
118125
Array.from(html).forEach(function (current) {
119126
current.querySelectorAll('.d-flex.Box-body > a').forEach(function (_this) {
120127
let href = _this.href.split('github.com'),
121-
url = [
122-
download_url[0][0] + '/' + _this.href,
123-
download_url[1][0] + '/' + _this.href,
124-
download_url[2][0] + '/' + _this.href,
125-
download_url[3][0] + href[1],
126-
download_url[4][0] + '/' + _this.href,
127-
download_url[5][0] + '/' + _this.href
128-
],
128+
url = [],
129129
_html = `<div style="display: flex;justify-content: flex-end;">`;
130+
131+
for (let i=0;i<download_url.length;i++){
132+
if (download_url[i][0] === 'https://download.fastgit.org') {
133+
url[i] = download_url[i][0] + href[1]
134+
} else {
135+
url[i] = download_url[i][0] + '/' + _this.href
136+
}
137+
}
138+
130139
for (let i=0;i<url.length;i++) {
131140
_html += `<a style="${style[0]}" class="btn" href="${url[i]}" rel="noreferrer noopener nofollow">${download_url[i][1]}</a>`
132141
}
@@ -140,15 +149,17 @@
140149
// Source Code
141150
current.querySelectorAll('.d-block.Box-body > a').forEach(function (_this) {
142151
let href = _this.href.split('github.com'),
143-
url = [
144-
download_url[0][0] + '/' + _this.href,
145-
download_url[1][0] + '/' + _this.href,
146-
download_url[2][0] + '/' + _this.href,
147-
download_url[3][0] + href[1],
148-
download_url[4][0] + '/' + _this.href,
149-
download_url[5][0] + '/' + _this.href
150-
],
152+
url = [],
151153
_html = `<div style="display: flex;justify-content: flex-end;flex-grow: 1;">`;
154+
155+
for (let i=0;i<download_url.length;i++){
156+
if (download_url[i][0] === 'https://download.fastgit.org') {
157+
url[i] = download_url[i][0] + href[1]
158+
} else {
159+
url[i] = download_url[i][0] + '/' + _this.href
160+
}
161+
}
162+
152163
for (let i=0;i<url.length;i++) {
153164
_html += `<a style="${style[0]}" class="btn" href="${url[i]}" rel="noreferrer noopener nofollow">${download_url[i][1]}</a>`
154165
}
@@ -165,15 +176,17 @@
165176
function addDownloadZIP() {
166177
let html = document.querySelector('.dropdown-menu.dropdown-menu-sw.p-0 ul li:last-child');if (!html) return
167178
let href = html.getElementsByTagName('a')[0].href,
168-
url = [
169-
download_url[0][0] + "/" + href,
170-
download_url[1][0] + "/" + href,
171-
download_url[2][0] + "/" + href,
172-
download_url[3][0] + href.split('github.com')[1],
173-
download_url[4][0] + "/" + href,
174-
download_url[5][0] + '/' + href
175-
],
179+
url = [],
176180
_html = ``;
181+
182+
for (let i=0;i<download_url.length;i++){
183+
if (download_url[i][0] === 'https://download.fastgit.org') {
184+
url[i] = download_url[i][0] + href.split('github.com')[1]
185+
} else {
186+
url[i] = download_url[i][0] + '/' + href
187+
}
188+
}
189+
177190
for (let i=0;i<url.length;i++) {
178191
_html += `<li class="Box-row Box-row--hover-gray p-0"><a class="d-flex flex-items-center color-text-primary text-bold no-underline p-3" rel="noreferrer noopener nofollow" href="${url[i]}">${svg[0]}Download ZIP ${download_url[i][1]}</a></li>`
179192
}
@@ -183,21 +196,44 @@
183196

184197
// Git Clone
185198
function addGitClone() {
186-
let html = document.querySelector('[role="tabpanel"] div.input-group');if (!html) return
187-
let href_split = html.querySelector('input').getAttribute('value').split('github.com'),
188-
url = [
189-
clone_url[0][0] + href_split[1],
190-
clone_url[1][0] + '/github.com' + href_split[1],
191-
clone_url[2][0] + href_split[1]
192-
],
199+
let html = document.querySelector('[role="tabpanel"]:nth-child(2) div.input-group');if (!html) return
200+
let href_split = html.getElementsByTagName('input')[0].getAttribute('value').split('github.com'),
201+
url = [],
193202
_html = ``;
203+
204+
for (let i=0;i<clone_url.length;i++){
205+
if (clone_url[i][0] === 'https://gitclone.com') {
206+
url[i] = clone_url[i][0] + '/github.com' + href_split[1]
207+
} else {
208+
url[i] = clone_url[i][0] + href_split[1]
209+
}
210+
}
211+
194212
for (let i=0;i<url.length;i++) {
195213
_html += `<div class="input-group" style="margin-top: 4px;" title="加速源:${clone_url[i][1]} (点击可直接复制)"><input value="${url[i]}" aria-label="${url[i]}" type="text" class="form-control input-monospace input-sm bg-gray-light" data-autoselect="" readonly=""><div class="input-group-button"><clipboard-copy value="${url[i]}" aria-label="Copy to clipboard" class="btn btn-sm" tabindex="0" role="button">${svg[1]}</clipboard-copy></div></div>`
196214
}
197215
html.insertAdjacentHTML('afterend', _html);
198216
}
199217

200218

219+
// Git Clone SSH
220+
function addGitCloneSSH() {
221+
let html = document.querySelector('[role="tabpanel"]:nth-child(3) div.input-group');if (!html) return
222+
let href_split = html.getElementsByTagName('input')[0].getAttribute('value').split(':'),
223+
url = [],
224+
_html = ``;
225+
226+
for (let i=0;i<clone_ssh_url.length;i++){
227+
url[i] = clone_ssh_url[i][0] + ':' + href_split[1]
228+
}
229+
230+
for (let i=0;i<url.length;i++) {
231+
_html += `<div class="input-group" style="margin-top: 4px;" title="加速源:${clone_ssh_url[i][1]} (点击可直接复制)"><input value="${url[i]}" aria-label="${url[i]}" type="text" class="form-control input-monospace input-sm bg-gray-light" data-autoselect="" readonly=""><div class="input-group-button"><clipboard-copy value="${url[i]}" aria-label="Copy to clipboard" class="btn btn-sm" tabindex="0" role="button">${svg[1]}</clipboard-copy></div></div>`
232+
}
233+
html.insertAdjacentHTML('afterend', _html);
234+
}
235+
236+
201237
// Raw
202238
function addRawFile() {
203239
let html = document.getElementById('raw-url');if (!html) return

0 commit comments

Comments
 (0)