|
1 | 1 | // ==UserScript== |
2 | 2 | // @name Github 增强 - 高速下载 |
3 | | -// @version 1.5.4 |
| 3 | +// @version 1.5.5 |
4 | 4 | // @author X.I.U |
5 | 5 | // @description 高速下载 Git Clone/SSH、Release、Raw、Code(ZIP) 等文件、项目列表单文件快捷下载 (☁) |
6 | 6 | // @match *://github.com/* |
|
143 | 143 | } |
144 | 144 | Array.from(html).forEach(function (current) { |
145 | 145 | current.querySelectorAll('.d-flex.Box-body > a').forEach(function (_this) { |
146 | | - let href = _this.href.split('github.com'), |
| 146 | + let href = _this.href.split(location.host), |
147 | 147 | url = [], |
148 | 148 | _html = `<div style="${divDisplay}justify-content: flex-end;">`; |
149 | 149 |
|
|
153 | 153 | } else { |
154 | 154 | url[i] = download_url[i][0] + '/' + _this.href |
155 | 155 | } |
| 156 | + if (location.host === 'hub.fastgit.org') url[i] = url[i].replace('hub.fastgit.org','github.com') |
156 | 157 | } |
157 | 158 |
|
158 | 159 | for (let i=0;i<url.length;i++) { |
|
167 | 168 |
|
168 | 169 | // Source Code |
169 | 170 | current.querySelectorAll('.d-block.Box-body > a').forEach(function (_this) { |
170 | | - let href = _this.href.split('github.com'), |
| 171 | + let href = _this.href.split(location.host), |
171 | 172 | url = [], |
172 | 173 | _html = `<div style="${divDisplay}justify-content: flex-end;flex-grow: 1;">`; |
173 | 174 |
|
|
177 | 178 | } else { |
178 | 179 | url[i] = download_url[i][0] + '/' + _this.href |
179 | 180 | } |
| 181 | + if (location.host === 'hub.fastgit.org') url[i] = url[i].replace('hub.fastgit.org','github.com') |
180 | 182 | } |
181 | 183 |
|
182 | 184 | for (let i=0;i<url.length;i++) { |
|
200 | 202 |
|
201 | 203 | for (let i=0;i<download_url.length;i++){ |
202 | 204 | if (download_url[i][0] === 'https://download.fastgit.org') { |
203 | | - url[i] = download_url[i][0] + href.split('github.com')[1] |
| 205 | + url[i] = download_url[i][0] + href.split(location.host)[1] |
204 | 206 | } else { |
205 | 207 | url[i] = download_url[i][0] + '/' + href |
206 | 208 | } |
| 209 | + if (location.host === 'hub.fastgit.org') url[i] = url[i].replace('hub.fastgit.org','github.com') |
207 | 210 | } |
208 | 211 |
|
209 | 212 | for (let i=0;i<url.length;i++) { |
|
216 | 219 | // Git Clone |
217 | 220 | function addGitClone() { |
218 | 221 | let html = document.querySelector('[role="tabpanel"]:nth-child(2) div.input-group');if (!html) return |
219 | | - let href_split = html.getElementsByTagName('input')[0].getAttribute('value').split('github.com'), |
| 222 | + let href_split = html.getElementsByTagName('input')[0].getAttribute('value').split(location.host), |
220 | 223 | url = [], |
221 | 224 | _html = ``; |
222 | 225 |
|
|
258 | 261 | // Raw |
259 | 262 | function addRawFile() { |
260 | 263 | let html = document.getElementById('raw-url');if (!html) return |
261 | | - let href = location.href.replace('https://github.com',''), |
| 264 | + let href = location.href.replace(`https://${location.host}`,''), |
262 | 265 | href2 = href.replace('/blob/','/'), |
263 | 266 | url = [ |
264 | 267 | raw_url[1][0] + "/gh" + href.replace('/blob/','@'), |
|
304 | 307 | cntElm_a = trElm.querySelector('.css-truncate.css-truncate-target.d-block.width-fit a'), |
305 | 308 | cntElm_svg = trElm.querySelector('.mr-3.flex-shrink-0 svg.octicon.octicon-file.color-icon-tertiary'), |
306 | 309 | Name = cntElm_a.innerText, |
307 | | - href = cntElm_a.attributes.href.nodeValue.replace('https://github.com',''); |
| 310 | + href = cntElm_a.attributes.href.nodeValue.replace(`https://${location.host}`,''); |
308 | 311 | let href2 = href.replace('/blob/','/'), url, url_name, url_tip = ''; |
309 | 312 | switch(menu_raw_fast) { |
310 | 313 | case 1: |
|
0 commit comments