|
1 | 1 | // ==UserScript== |
2 | 2 | // @name Github 增强 - 高速下载 |
3 | | -// @version 1.0.7 |
| 3 | +// @version 1.0.8 |
4 | 4 | // @author X.I.U |
5 | | -// @description 为 Github 的 Clone、Release、Code(ZIP) 添加高速下载 |
| 5 | +// @description 为 Github 的 Clone、Release、Raw、Code(ZIP) 添加高速下载 |
6 | 6 | // @match https://github.com/*/* |
7 | 7 | // @match https://github.com/*/*/releases |
8 | 8 | // @match https://github.com/*/*/releases/* |
|
16 | 16 | (function() { |
17 | 17 | var source_code = true; // Source code 加速,false=关闭,true=开启 |
18 | 18 | var git_clone = true; // Git Clone 加速,false=关闭,true=开启 |
| 19 | + var raw_file = true; // Raw 加速,false=关闭,true=开启 |
19 | 20 | var download_url1 = "https://download.fastgit.org"; |
20 | 21 | var download_url1_name = "日本东京"; |
21 | 22 | var download_url2 = "https://gh.con.sh"; |
|
27 | 28 | var download_url5 = "https://git.yumenaka.net"; |
28 | 29 | var download_url5_name = "美国洛杉矶"; |
29 | 30 | var clone_url1 = "https://hub.fastgit.org"; // 中国香港 |
30 | | - var clone_url2 = "https://ghp.lvmhsh.cn.cnpmjs.org"; // 新加坡 |
| 31 | + var clone_url2 = "https://gitclone.com"; // 中国浙江杭州 |
| 32 | + var clone_url3 = "https://ghp.lvmhsh.cn.cnpmjs.org"; // 新加坡 |
| 33 | + var raw_url1 = "https://cdn.jsdelivr.net"; // 中国国内CDN |
31 | 34 | var download_zip_svg = `<svg class="octicon octicon-file-zip mr-3" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M3.5 1.75a.25.25 0 01.25-.25h3a.75.75 0 000 1.5h.5a.75.75 0 000-1.5h2.086a.25.25 0 01.177.073l2.914 2.914a.25.25 0 01.073.177v8.586a.25.25 0 01-.25.25h-.5a.75.75 0 000 1.5h.5A1.75 1.75 0 0014 13.25V4.664c0-.464-.184-.909-.513-1.237L10.573.513A1.75 1.75 0 009.336 0H3.75A1.75 1.75 0 002 1.75v11.5c0 .649.353 1.214.874 1.515a.75.75 0 10.752-1.298.25.25 0 01-.126-.217V1.75zM8.75 3a.75.75 0 000 1.5h.5a.75.75 0 000-1.5h-.5zM6 5.25a.75.75 0 01.75-.75h.5a.75.75 0 010 1.5h-.5A.75.75 0 016 5.25zm2 1.5A.75.75 0 018.75 6h.5a.75.75 0 010 1.5h-.5A.75.75 0 018 6.75zm-1.25.75a.75.75 0 000 1.5h.5a.75.75 0 000-1.5h-.5zM8 9.75A.75.75 0 018.75 9h.5a.75.75 0 010 1.5h-.5A.75.75 0 018 9.75zm-.75.75a1.75 1.75 0 00-1.75 1.75v3c0 .414.336.75.75.75h2.5a.75.75 0 00.75-.75v-3a1.75 1.75 0 00-1.75-1.75h-.5zM7 12.25a.25.25 0 01.25-.25h.5a.25.25 0 01.25.25v2.25H7v-2.25z"></path></svg>`; |
32 | 35 | var download_clone_svg = `<svg class="octicon octicon-clippy" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M5.75 1a.75.75 0 00-.75.75v3c0 .414.336.75.75.75h4.5a.75.75 0 00.75-.75v-3a.75.75 0 00-.75-.75h-4.5zm.75 3V2.5h3V4h-3zm-2.874-.467a.75.75 0 00-.752-1.298A1.75 1.75 0 002 3.75v9.5c0 .966.784 1.75 1.75 1.75h8.5A1.75 1.75 0 0014 13.25v-9.5a1.75 1.75 0 00-.874-1.515.75.75 0 10-.752 1.298.25.25 0 01.126.217v9.5a.25.25 0 01-.25.25h-8.5a.25.25 0 01-.25-.25v-9.5a.25.25 0 01.126-.217z"></path></svg>` |
33 | 36 | var download_release_style = `padding:0 4px;margin-right: -1px;border-radius: 2px;background-color: #ffffff;border-color: rgba(27, 31, 35, 0.1);font-size: 12px;` |
|
82 | 85 | var url3 = download_url3 + "/github.com" + href; |
83 | 86 | var url4 = download_url4 + "/github.com" + href; |
84 | 87 | var url5 = download_url5 + "/github.com" + href; |
85 | | - var html1 = `<li class="Box-row Box-row--hover-gray p-0"><a class="d-flex flex-items-center text-gray-dark text-bold no-underline p-3" rel="nofollow" href="${url1}">${download_zip_svg}Download ZIP ${download_url1_name}</a></li> |
| 88 | + var html1 = ` |
| 89 | +<li class="Box-row Box-row--hover-gray p-0"><a class="d-flex flex-items-center text-gray-dark text-bold no-underline p-3" rel="nofollow" href="${url1}">${download_zip_svg}Download ZIP ${download_url1_name}</a></li> |
86 | 90 | <li class="Box-row Box-row--hover-gray p-0"><a class="d-flex flex-items-center text-gray-dark text-bold no-underline p-3" rel="nofollow" href="${url2}">${download_zip_svg}Download ZIP ${download_url2_name}</a></li> |
87 | 91 | <li class="Box-row Box-row--hover-gray p-0"><a class="d-flex flex-items-center text-gray-dark text-bold no-underline p-3" rel="nofollow" href="${url3}">${download_zip_svg}Download ZIP ${download_url3_name}</a></li> |
88 | 92 | <li class="Box-row Box-row--hover-gray p-0"><a class="d-flex flex-items-center text-gray-dark text-bold no-underline p-3" rel="nofollow" href="${url4}">${download_zip_svg}Download ZIP ${download_url4_name}</a></li> |
|
95 | 99 | $("[role='tabpanel'] div.input-group").first().each(function () { |
96 | 100 | var href_split = location.href.split("/"); |
97 | 101 | var url1 = clone_url1 + "/" + href_split[3] + "/" + href_split[4] + ".git"; |
98 | | - var url2 = clone_url2 + "/" + href_split[3] + "/" + href_split[4] + ".git"; |
99 | | - var html1 = `<div class="input-group" style="margin-top: 4px;"><input value="${url1}" aria-label="${url1}" type="text" class="form-control input-monospace input-sm bg-gray-light" data-autoselect="" readonly=""><div class="input-group-button"><clipboard-copy value="${url1}" aria-label="Copy to clipboard" class="btn btn-sm" tabindex="0" role="button">${download_clone_svg}</clipboard-copy></div></div> |
100 | | -<div class="input-group" style="margin-top: 4px;"><input value="${url2}" aria-label="${url2}" type="text" class="form-control input-monospace input-sm bg-gray-light" data-autoselect="" readonly=""><div class="input-group-button"><clipboard-copy value="${url2}" aria-label="Copy to clipboard" class="btn btn-sm" tabindex="0" role="button">${download_clone_svg}</clipboard-copy></div></div>`; |
| 102 | + var url2 = clone_url2 + "/github.com/" + href_split[3] + "/" + href_split[4] + ".git"; |
| 103 | + var url3 = clone_url3 + "/" + href_split[3] + "/" + href_split[4] + ".git"; |
| 104 | + var html1 = ` |
| 105 | +<div class="input-group" style="margin-top: 4px;"><input value="${url1}" aria-label="${url1}" type="text" class="form-control input-monospace input-sm bg-gray-light" data-autoselect="" readonly=""><div class="input-group-button"><clipboard-copy value="${url1}" aria-label="Copy to clipboard" class="btn btn-sm" tabindex="0" role="button">${download_clone_svg}</clipboard-copy></div></div> |
| 106 | +<div class="input-group" style="margin-top: 4px;"><input value="${url2}" aria-label="${url2}" type="text" class="form-control input-monospace input-sm bg-gray-light" data-autoselect="" readonly=""><div class="input-group-button"><clipboard-copy value="${url2}" aria-label="Copy to clipboard" class="btn btn-sm" tabindex="0" role="button">${download_clone_svg}</clipboard-copy></div></div> |
| 107 | +<div class="input-group" style="margin-top: 4px;"><input value="${url3}" aria-label="${url3}" type="text" class="form-control input-monospace input-sm bg-gray-light" data-autoselect="" readonly=""><div class="input-group-button"><clipboard-copy value="${url3}" aria-label="Copy to clipboard" class="btn btn-sm" tabindex="0" role="button">${download_clone_svg}</clipboard-copy></div></div> |
| 108 | +`; |
| 109 | + $(this).after(html1); |
| 110 | + }); |
| 111 | + } |
| 112 | + // Raw 加速,默认开启 |
| 113 | + if (raw_file){ |
| 114 | + $("#raw-url").each(function () { |
| 115 | + var href = location.href.replace('https://github.com','').replace('/blob/','@'); |
| 116 | + var url1 = raw_url1 + "/gh" + href; |
| 117 | + var html1 = `<a href="${url1}" role="button" class="btn btn-sm BtnGroup-item">高速下载</a>`; |
101 | 118 | $(this).after(html1); |
102 | 119 | }); |
103 | 120 | } |
|
0 commit comments