|
4 | 4 | // @description GitHub镜像,加速访问GitHub,支持Clone、Release、Raw、Zip加速。
|
5 | 5 | // @description:en GitHub mirror. Accelerate access to GitHub. Support Clone, Release, RAW and ZIP acceleration.
|
6 | 6 | // @namespace https://github.com/HaleShaw
|
7 |
| -// @version 1.1.0 |
| 7 | +// @version 1.2.0 |
8 | 8 | // @author HaleShaw
|
9 | 9 | // @copyright 2021+, HaleShaw (https://github.com/HaleShaw)
|
10 | 10 | // @license AGPL-3.0-or-later
|
|
187 | 187 | if (location.pathname.split('/')[3] == 'releases') {
|
188 | 188 | addReleasesList();
|
189 | 189 | }
|
| 190 | + if (isPC) { |
| 191 | + addDownloadZip(); |
| 192 | + } |
190 | 193 | }
|
191 | 194 |
|
192 | 195 | /**
|
|
410 | 413 | </a>`;
|
411 | 414 | }
|
412 | 415 |
|
| 416 | + /** |
| 417 | + * Add Release list. |
| 418 | + */ |
413 | 419 | function addReleasesList() {
|
414 | 420 | $('.Box--condensed')
|
415 | 421 | .find('[href]')
|
|
422 | 428 | });
|
423 | 429 | }
|
424 | 430 |
|
| 431 | + /** |
| 432 | + * Get Release download button html string. |
| 433 | + * @param {String} href href. |
| 434 | + * @returns html. |
| 435 | + */ |
425 | 436 | function getReleaseDownloadHtml(href) {
|
426 |
| - let span = ''; |
| 437 | + let html = ''; |
427 | 438 | downloadSet.forEach(id => {
|
428 |
| - span += `<a class="flex-1 btn btn-outline get-repo-btn" rel="nofollow" href="${ |
| 439 | + html += `<a class="flex-1 btn btn-outline get-repo-btn" rel="nofollow" href="${ |
429 | 440 | mirrors[id]['url'] + href
|
430 | 441 | }" title="${mirrors[id]['description']}">${mirrors[id]['name']}</a>`;
|
431 | 442 | });
|
432 |
| - return span; |
| 443 | + return html; |
| 444 | + } |
| 445 | + |
| 446 | + /** |
| 447 | + * Add download zip button. |
| 448 | + */ |
| 449 | + function addDownloadZip() { |
| 450 | + $("a[data-open-app='link']").each(function () { |
| 451 | + var li = $(`<li class="Box-row p-0"></li>`); |
| 452 | + const downloadHref = $(this).attr('href'); |
| 453 | + var aElement = $(this) |
| 454 | + .clone() |
| 455 | + .removeAttr('data-hydro-click data-hydro-click-hmac data-ga-click'); |
| 456 | + aElement.addClass('Box-row Box-row--hover-gray'); |
| 457 | + downloadSet.forEach(id => { |
| 458 | + let tempA = aElement.clone(); |
| 459 | + tempA.attr({ |
| 460 | + href: mirrors[id]['url'] + downloadHref, |
| 461 | + title: mirrors[id]['description'] |
| 462 | + }); |
| 463 | + tempA.html( |
| 464 | + tempA.html().replace('Download ZIP', `Download ZIP(${mirrors[id]['name']})`) |
| 465 | + ); |
| 466 | + li = li.clone().append(tempA); |
| 467 | + }); |
| 468 | + $(this).parent().after(li); |
| 469 | + }); |
433 | 470 | }
|
434 | 471 |
|
435 | 472 | /**
|
|
0 commit comments