|
1 | 1 | // ==UserScript== |
2 | 2 | // @name Github 增强 - 高速下载 |
3 | | -// @version 1.6.6 |
| 3 | +// @version 1.6.7 |
4 | 4 | // @author X.I.U |
5 | 5 | // @description 高速下载 Git Clone/SSH、Release、Raw、Code(ZIP) 等文件、项目列表单文件快捷下载 (☁) |
6 | 6 | // @match *://github.com/* |
|
21 | 21 |
|
22 | 22 | (function() { |
23 | 23 | 'use strict'; |
24 | | - var backColor = '#ffffff'; |
25 | | - var fontColor = '#888888'; |
| 24 | + var backColor = '#ffffff', fontColor = '#888888'; |
26 | 25 | if (document.getElementsByTagName('html')[0].getAttribute('data-color-mode') === 'dark') { // 黑暗模式判断 |
27 | 26 | if (document.getElementsByTagName('html')[0].getAttribute('data-dark-theme') === 'dark_dimmed') { |
28 | | - backColor = '#272e37'; |
29 | | - fontColor = '#768390'; |
| 27 | + backColor = '#272e37'; fontColor = '#768390'; |
30 | 28 | } else { |
31 | | - backColor = '#161a21'; |
32 | | - fontColor = '#97a0aa'; |
| 29 | + backColor = '#161a21'; fontColor = '#97a0aa'; |
33 | 30 | } |
34 | 31 | } else if (document.getElementsByTagName('html')[0].getAttribute('data-color-mode') === 'auto') { |
35 | | - //console.log(window.getComputedStyle(document.body).backgroundColor) |
36 | 32 | if (window.getComputedStyle(document.body).backgroundColor === 'rgb(34, 39, 46)') { |
37 | | - backColor = '#272e37'; |
38 | | - fontColor = '#768390'; |
| 33 | + backColor = '#272e37'; fontColor = '#768390'; |
39 | 34 | } else if (window.getComputedStyle(document.body).backgroundColor === 'rgb(13, 17, 23)') { |
40 | | - backColor = '#161a21'; |
41 | | - fontColor = '#97a0aa'; |
| 35 | + backColor = '#161a21'; fontColor = '#97a0aa'; |
42 | 36 | } |
43 | 37 | } |
44 | 38 | const download_url = [ |
45 | | - ['https://gh.api.99988866.xyz', '美国 1'], |
46 | | - ['https://github.91chifun.workers.dev', '美国 2'], |
47 | | - ['https://gh.xiu2.xyz', '美国 3'], |
| 39 | + ['https://gh.api.99988866.xyz/https://github.com', '美国 1'], |
| 40 | + ['https://github.91chifun.workers.dev/https://github.com', '美国 2'], |
| 41 | + ['https://gh.xiu2.xyz/https://github.com', '美国 3'], |
48 | 42 | ['https://github.rc1844.workers.dev', '美国 4'], |
49 | | - ['https://pd.zwc365.com/seturl', '美国 5'], |
| 43 | + ['https://pd.zwc365.com/seturl/https://github.com', '美国 5'], |
50 | 44 | ['https://download.fastgit.org', '日本'], |
51 | | - ['https://ghproxy.com', '韩国'] |
| 45 | + ['https://ghproxy.com/https://github.com/', '韩国'] |
52 | 46 | ], |
53 | 47 | clone_url = [ |
54 | 48 | ['https://hub.fastgit.org', '中国香港'], |
|
132 | 126 |
|
133 | 127 | // Release |
134 | 128 | function addRelease() { |
135 | | - let html = document.getElementsByClassName('Box-footer');//if (html.length == 0) return |
| 129 | + let html = document.getElementsByClassName('Box-footer'); if (html.length == 0) return |
136 | 130 | let divDisplay = ''; |
137 | | - if (html.length > 0) { |
138 | | - if (document.documentElement.clientWidth > 1000) {divDisplay = 'float: right;margin-top: -3px;margin-left: 8px;';}; // 调整小屏幕下样式 |
139 | | - Array.from(html).forEach(function (current) { |
140 | | - current.querySelectorAll('li.Box-row > a').forEach(function (_this) { |
141 | | - let href = _this.href.split(location.host), |
142 | | - url = [], |
143 | | - _html = `<div style="${divDisplay}">`; |
144 | | - |
145 | | - for (let i=0;i<download_url.length;i++){ |
146 | | - console.log(download_url[i][0]) |
147 | | - if (download_url[i][0] === 'https://download.fastgit.org' || download_url[i][0] === 'https://github.rc1844.workers.dev') { |
148 | | - url[i] = download_url[i][0] + href[1] |
149 | | - } else { |
150 | | - url[i] = download_url[i][0] + '/' + _this.href |
151 | | - } |
152 | | - if (location.host === 'hub.fastgit.org') url[i] = url[i].replace('hub.fastgit.org','github.com') |
153 | | - } |
154 | | - |
155 | | - for (let i=0;i<url.length;i++) { |
156 | | - _html += `<a style="${style[0]}" class="btn" href="${url[i]}" rel="noreferrer noopener nofollow">${download_url[i][1]}</a>` |
157 | | - } |
158 | | - _html += `</div>` |
159 | | - _this.insertAdjacentHTML('afterend', _html); |
160 | | - }); |
| 131 | + if (document.documentElement.clientWidth > 1000) {divDisplay = 'float: right;margin-top: -3px;margin-left: 8px;';}; // 调整小屏幕时的样式 |
| 132 | + Array.from(html).forEach(function (current) { |
| 133 | + current.querySelectorAll('li.Box-row > a').forEach(function (_this) { |
| 134 | + let href = _this.href.split(location.host), |
| 135 | + url = [], |
| 136 | + _html = `<div style="${divDisplay}">`; |
| 137 | + // 循环组合 URL 链接 |
| 138 | + for (let i=0;i<download_url.length;i++){ |
| 139 | + url[i] = download_url[i][0] + href[1] |
| 140 | + if (location.host === 'hub.fastgit.org') url[i] = url[i].replace('hub.fastgit.org','github.com') |
| 141 | + if (download_url[i][0] === 'https://download.fastgit.org' && url[i].indexOf('/archive/') > -1) url[i] = url[i].replace('https://download.fastgit.org','https://archive.fastgit.org') |
| 142 | + } |
| 143 | + // 循环生成 HTML 标签 |
| 144 | + for (let i=0;i<url.length;i++) { |
| 145 | + _html += `<a style="${style[0]}" class="btn" href="${url[i]}" rel="noreferrer noopener nofollow">${download_url[i][1]}</a>` |
| 146 | + } |
| 147 | + _html += `</div>` |
| 148 | + _this.insertAdjacentHTML('afterend', _html); |
161 | 149 | }); |
162 | | - } else if (document.getElementsByClassName('Box Box--condensed').length > 0) { |
163 | | - html = document.getElementsByClassName('Box Box--condensed') |
164 | | - if (document.documentElement.clientWidth > 1000) {divDisplay = 'display: flex;';} else {divDisplay = 'display: block;';} |
165 | | - Array.from(html).forEach(function (current) { |
166 | | - current.querySelectorAll('.d-flex.Box-body > a').forEach(function (_this) { |
167 | | - let href = _this.href.split(location.host), |
168 | | - url = [], |
169 | | - _html = `<div style="${divDisplay}justify-content: flex-end;">`; |
170 | | - |
171 | | - for (let i=0;i<download_url.length;i++){ |
172 | | - console.log(download_url[i][0]) |
173 | | - if (download_url[i][0] === 'https://download.fastgit.org' || download_url[i][0] === 'https://github.rc1844.workers.dev') { |
174 | | - url[i] = download_url[i][0] + href[1] |
175 | | - } else { |
176 | | - url[i] = download_url[i][0] + '/' + _this.href |
177 | | - } |
178 | | - if (location.host === 'hub.fastgit.org') url[i] = url[i].replace('hub.fastgit.org','github.com') |
179 | | - } |
180 | | - |
181 | | - for (let i=0;i<url.length;i++) { |
182 | | - _html += `<a style="${style[0]}" class="btn" href="${url[i]}" rel="noreferrer noopener nofollow">${download_url[i][1]}</a>` |
183 | | - } |
184 | | - _html += `</div>` |
185 | | - _this.nextElementSibling.insertAdjacentHTML('afterend', _html); |
186 | | - }); |
187 | | - // 修改[文件大小]元素样式 |
188 | | - document.querySelectorAll('.Box.Box--condensed small').forEach(el=>{el.style.cssText='display: flex; justify-content: flex-end; flex-grow: 1; margin-right: 8px;'}); |
189 | | - |
190 | | - |
191 | | - // Source Code |
192 | | - current.querySelectorAll('.d-block.Box-body > a').forEach(function (_this) { |
193 | | - let href = _this.href.split(location.host), |
194 | | - url = [], |
195 | | - _html = `<div style="${divDisplay}justify-content: flex-end;flex-grow: 1;">`; |
196 | | - |
197 | | - for (let i=0;i<download_url.length;i++){ |
198 | | - if (download_url[i][0] === 'https://download.fastgit.org') { |
199 | | - url[i] = download_url[i][0] + href[1] |
200 | | - } else { |
201 | | - url[i] = download_url[i][0] + '/' + _this.href |
202 | | - } |
203 | | - if (location.host === 'hub.fastgit.org') url[i] = url[i].replace('hub.fastgit.org','github.com') |
204 | | - } |
205 | | - |
206 | | - for (let i=0;i<url.length;i++) { |
207 | | - _html += `<a style="${style[0]}" class="btn" href="${url[i]}" rel="noreferrer noopener nofollow">${download_url[i][1]}</a>` |
208 | | - } |
209 | | - _html += `</div>` |
210 | | - _this.insertAdjacentHTML('afterend', _html); |
211 | | - }); |
212 | | - }); |
213 | | - // 修改 Source code 样式,使其和加速按钮并列一排 |
214 | | - document.querySelectorAll('div.d-block.py-1.py-md-2.Box-body.px-2').forEach(el=>{el.className='d-flex py-1 py-md-2 Box-body px-2'}); |
215 | | - } else { |
216 | | - return |
217 | | - } |
| 150 | + }); |
218 | 151 | } |
219 | 152 |
|
220 | 153 |
|
|
227 | 160 | _html = ``; |
228 | 161 |
|
229 | 162 | for (let i=0;i<download_url.length;i++){ |
230 | | - if (download_url[i][0] === 'https://download.fastgit.org') { |
231 | | - url[i] = download_url[i][0] + href.split(location.host)[1] |
232 | | - } else { |
233 | | - url[i] = download_url[i][0] + '/' + href |
234 | | - } |
| 163 | + url[i] = download_url[i][0] + href.split(location.host)[1] |
235 | 164 | if (location.host === 'hub.fastgit.org') url[i] = url[i].replace('hub.fastgit.org','github.com') |
| 165 | + if (download_url[i][0] === 'https://download.fastgit.org' && url[i].indexOf('/archive/') > -1) url[i] = url[i].replace('https://download.fastgit.org','https://archive.fastgit.org') |
236 | 166 | } |
237 | 167 |
|
238 | 168 | for (let i=0;i<url.length;i++) { |
|
276 | 206 | if (href_split[0] != 'git@github.com') return |
277 | 207 |
|
278 | 208 | for (let i=0;i<clone_ssh_url.length;i++){ |
279 | | - url[i] = clone_ssh_url[i][0] + ':' + href_split[1] |
| 209 | + url[i] = clone_ssh_url[i][0] + ':' + href_split[1] |
280 | 210 | } |
281 | 211 |
|
282 | 212 | for (let i=0;i<url.length;i++) { |
|
0 commit comments