|
1 | 1 | // ==UserScript== |
2 | 2 | // @name Github 增强 - 高速下载 |
3 | | -// @version 1.4.8 |
| 3 | +// @version 1.4.9 |
4 | 4 | // @author X.I.U |
5 | 5 | // @description 高速下载 Git Clone、Release、Raw、Code(ZIP) 等文件、项目列表单文件快捷下载 (☁) |
6 | 6 | // @match *://github.com/* |
|
29 | 29 | fontColor = '#b2b8bf'; |
30 | 30 | } |
31 | 31 | } |
32 | | - |
| 32 | +//['https://github.91chifun.workers.dev','美国'], |
33 | 33 | var download_url = [ |
34 | 34 | ['https://gh.api.99988866.xyz','美国'], |
35 | | - ['https://github.91chifun.workers.dev','美国'], |
| 35 | + ['https://gh.msx.workers.dev','美国'], |
36 | 36 | ['https://gh.xiu2.xyz','美国'], |
| 37 | + ['https://git.yumenaka.net','美国洛杉矶'], |
37 | 38 | ['https://download.fastgit.org','日本东京'], |
38 | 39 | ['https://ghproxy.com','韩国首尔'], |
39 | 40 | ['https://pd.zwc365.com/seturl','中国香港'] |
40 | 41 | ], |
41 | 42 | clone_url = [ |
42 | 43 | ['https://hub.fastgit.org','中国香港'], |
43 | | - ['https://gitclone.com','中国浙江杭州'], |
| 44 | + ['https://gitclone.com','中国浙江'], |
44 | 45 | ['https://ghp.lvmhsh.cn.cnpmjs.org','新加坡'] |
45 | 46 | ], |
| 47 | + clone_ssh_url = [ |
| 48 | + ['git@git.zhlh6.cn','中国北京'], |
| 49 | + ['git@hub.fastgit.org','中国香港'] |
| 50 | + ], |
46 | 51 | raw_url = [ |
47 | 52 | ['https://raw.githubusercontent.com','Github 原生',''], |
48 | 53 | ['https://cdn.jsdelivr.net','中国国内','注意:该加速源存在缓存机制(24小时),所以文件可能不是最新。 注意:当前分支所有文件总文件大小超过 50MB 时,该加速源不可用。 注意:当前分支名为版本号格式时(如 v1.2.3),该高速下载链接因格式限制不可用。'], |
|
89 | 94 | }; |
90 | 95 |
|
91 | 96 | 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 加速 |
94 | 100 | addRawFile(); // Raw 加速 |
95 | 101 | setTimeout(addRawDownLink, 2000); // 添加 Raw 下载链接(☁),延迟 2 秒执行,避免被 pjax 刷掉 |
96 | 102 |
|
97 | 103 | document.addEventListener('pjax:success',function(){ // pjax 事件发生后 |
98 | 104 | 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 加速 |
102 | 109 | setTimeout(addRawDownLink, 2000); // 添加 Raw 下载链接(☁),延迟 2 秒执行,避免被 pjax 刷掉 |
103 | 110 | }); |
104 | 111 |
|
|
118 | 125 | Array.from(html).forEach(function (current) { |
119 | 126 | current.querySelectorAll('.d-flex.Box-body > a').forEach(function (_this) { |
120 | 127 | 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 = [], |
129 | 129 | _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 | + |
130 | 139 | for (let i=0;i<url.length;i++) { |
131 | 140 | _html += `<a style="${style[0]}" class="btn" href="${url[i]}" rel="noreferrer noopener nofollow">${download_url[i][1]}</a>` |
132 | 141 | } |
|
140 | 149 | // Source Code |
141 | 150 | current.querySelectorAll('.d-block.Box-body > a').forEach(function (_this) { |
142 | 151 | 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 = [], |
151 | 153 | _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 | + |
152 | 163 | for (let i=0;i<url.length;i++) { |
153 | 164 | _html += `<a style="${style[0]}" class="btn" href="${url[i]}" rel="noreferrer noopener nofollow">${download_url[i][1]}</a>` |
154 | 165 | } |
|
165 | 176 | function addDownloadZIP() { |
166 | 177 | let html = document.querySelector('.dropdown-menu.dropdown-menu-sw.p-0 ul li:last-child');if (!html) return |
167 | 178 | 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 = [], |
176 | 180 | _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 | + |
177 | 190 | for (let i=0;i<url.length;i++) { |
178 | 191 | _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>` |
179 | 192 | } |
|
183 | 196 |
|
184 | 197 | // Git Clone |
185 | 198 | 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 = [], |
193 | 202 | _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 | + |
194 | 212 | for (let i=0;i<url.length;i++) { |
195 | 213 | _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>` |
196 | 214 | } |
197 | 215 | html.insertAdjacentHTML('afterend', _html); |
198 | 216 | } |
199 | 217 |
|
200 | 218 |
|
| 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 | + |
201 | 237 | // Raw |
202 | 238 | function addRawFile() { |
203 | 239 | let html = document.getElementById('raw-url');if (!html) return |
|
0 commit comments