GithubPlusPlus

高速下载 Git Release、Raw、Code(ZIP) 等文件

目前为 2022-03-12 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name GithubPlusPlus
  3. // @name:zh-CN GithubPlusPlus - 高速下载GitHub资源
  4. // @name:en GithubPlusPlus
  5. // @version 0.0.4
  6. // @author HackPig520
  7. // @description 高速下载 Git Release、Raw、Code(ZIP) 等文件
  8. // @description:zh-CN 高速下载 Git Release、Raw、Code(ZIP) 等文件
  9. // @description:en High-speed download of Git Release, Raw, Code(ZIP) and other files.
  10. // @match *://github.com/*
  11. // @match *://hub.fastgit.xyz/*
  12. // @match *://hub.fastgit.org/*
  13. // @match *://github.com.cnpmjs.org/*
  14. // @icon https://i.loli.net/2021/03/30/ULV9XunaHesqGIR.png
  15. // @require https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
  16. // @resource gpp_css https://gitee.com/Botme/UserScript/raw/master/index.css
  17. // @grant GM_registerMenuCommand
  18. // @grant GM_unregisterMenuCommand
  19. // @grant GM_openInTab
  20. // @grant GM_getValue
  21. // @grant GM_setValue
  22. // @grant GM_notification
  23. // @grant window.onurlchange
  24. // @license WTFPL License
  25. // @run-at document-end
  26. // @namespace https://greasyfork.org/scripts/441278
  27. // @supportURL https://gitee.com/botme/UserScript/issues
  28. // @homepageURL https://gitee.com/Botme/UserScript
  29. // ==/UserScript==
  30. (function () {
  31. var clone = true;//克隆相关
  32. var depth = true;//自动添加'--depth 1'参数,有助于提高Clone速度
  33. var hide = true;
  34.  
  35. var location = window.location.href; //当前页面地址
  36. /////////////////////
  37. var mirror_url1 = "https://github.com.cnpmjs.org"; //中国香港 - 已失效
  38. var mirror_url2 = "https://hub.fastgit.xyz"; //日本 - 正常
  39. var mirror_url3 = "https://index.pig2333.workers.dev"; //CloudFlare - 正常
  40. var mirror_url4 = "https://gh.xiu.workers.dev/https://github.com"; //CloudFlare - 正常
  41. var mirror_url5 = "https://ghgo.feizhuqwq.workers.dev/https://github.com"; //CloudFlare - 正常
  42. /////////////////////
  43. var download_url1 = "https://download.fastgit.org"; //美国 - 正常
  44. var download_url2 = "https://gh.ddlc.top/https://github.com"; //美国 - 正常
  45. var download_url3 = "https://git.yumenaka.net/https://github.com"; //美国 - 正常
  46. var str1 = ""; //定义空
  47.  
  48. if (clone) {
  49. str1 += "git clone "; //前缀
  50. if (depth) {
  51. str1 += "--depth=1 "; //自动添加'--depth 1'参数
  52. }
  53. }
  54.  
  55. var a = location.split("/"); //以'/'分割
  56. var b = a[5] === "wiki" ? ".wiki" : ""; //如果是WIKI
  57. var str2 = "/" + a[3] + "/" + a[4] + b + ".git";
  58. var clone_utl1 = str1 + mirror_url1 + str2; //Clone1链接拼接
  59. var clone_utl2 = str1 + mirror_url2 + str2; //Clone2链接拼接
  60. var clone_utl3 = str1 + mirror_url3 + str2; //Clone3链接拼接
  61. var clone_utl4 = str1 + mirror_url4 + str2; //Clone4链接拼接
  62. var str3 = window.location.pathname;
  63. var web_url1 = mirror_url1 + str3; //Web1链接拼接
  64. var web_url2 = mirror_url2 + str3; //Web2链接拼接
  65. var web_url3 = mirror_url3 + str3; //Web3链接拼接
  66. var web_url3 = mirror_url4 + str3; //Web4链接拼接
  67. // 镜像面板代码
  68. var info = `
  69. <div class="user-ment">
  70. <button class="btn btn-primary" type="button" id="mirror-btn">镜像网址</button>
  71. <div class="collapse multi-collapse" id="collapse">
  72. <div class="user-card user-card-body">
  73. <div class="user-alert user-alert-warning" role="alert">clonedepth命令的插入可手动编辑代码关闭</div>
  74. <div class="user-alert user-alert-danger" role="alert">镜像地址请不要登陆自己的账户,造成损失本人概不负责</div>
  75. <div class="user-input-group user-mb-3">
  76. <div class="user-input-group-prepend"><span class="user-input-group-text" id="inputGroup-sizing-default">快速克隆1:</span></div>
  77. <input id="clone_case_1" type="text" value="${clone_utl1}" data-autoselect="" class="user-form-control" aria-label="将此存储库克隆到 ${clone_utl1}" readonly aria-describedby="inputGroup-sizing-default">
  78. <div class="user-input-group-append">
  79. <button class="btn btn-outline-secondary" type="button" id="button-copy1" data-container="body" data-toggle="popover" data-placement="bottom" data-content="复制成功">复制</button>
  80. </div>
  81. <button class="btn btn-outline-secondary" type="button" id="quickView1" href="${web_url1}" class="btn">快速浏览1</button>
  82. </div>
  83. <div class="user-input-group user-mb-3">
  84. <div class="user-input-group-prepend">
  85. <span class="user-input-group-text" id="inputGroup-sizing-default">快速克隆2:</span>
  86. </div>
  87. <input id="clone_case_2" type="text" value="${clone_utl2}" data-autoselect="" class="user-form-control" aria-label="将此存储库克隆到 ${clone_utl2}" readonly aria-describedby="inputGroup-sizing-default">
  88. <div class="user-input-group-append">
  89. <button class="btn btn-outline-secondary" type="button" id="button-copy2" data-container="body" data-toggle="popover" data-placement="bottom" data-content="复制成功">复制</button>
  90. </div>
  91. <button class="btn btn-outline-secondary" type="button" id="quickView2" class="btn">快速浏览2</button>
  92. </div>
  93. <div class="user-input-group user-mb-3">
  94. <div class="user-input-group-prepend">
  95. <span class="user-input-group-text" id="inputGroup-sizing-default">快速克隆3:</span>
  96. </div>
  97. <input type="text" data-autoselect="" class="user-form-control" aria-describedby="inputGroup-sizing-default" value="不支持clone,直接跳转--->" aria-label="" readonly="">
  98. <button type="button" id="quickView3" class="btn">快速浏览3</button>
  99. </div>
  100. <div class="user-input-group user-mb-3">
  101. <div class="user-input-group-prepend">
  102. <span class="user-input-group-text" id="inputGroup-sizing-default">快速克隆4:</span>
  103. </div>
  104. <input type="text" data-autoselect="" class="user-form-control" aria-describedby="inputGroup-sizing-default" value="不支持clone,直接跳转--->" aria-label="" readonly="">
  105. <button type="button" id="quickView4" class="btn">快速浏览4</button>
  106. </div>
  107. </div>
  108. </div>
  109. </div>`;
  110.  
  111. // 菜单数字图标
  112. function menu_num(num) {
  113. return ['0️⃣', '1️⃣', '2️⃣', '3️⃣', '4️⃣', '5️⃣', '6️⃣', '7️⃣', '8️⃣', '9️⃣', '🔟'][num]
  114. }
  115. $(".repository-content").prepend(info);
  116. $(".Box.Box--condensed").each(function () {
  117. // 修改源代码下载栏样式
  118. $(this).find(".d-block.py-1.py-md-2.Box-body.px-2").addClass("d-flex flex-justify-between")
  119. // 修改文件大小对齐方式
  120. $(".pl-2.color-text-secondary.flex-shrink-0").css({ "display": "flex", "flex-grow": 1, "justify-content": "flex-end" })
  121. $(this).find(".d-flex.Box-body").each(function () {
  122. var href = $(this).children("a").attr("href");
  123. var url1 = download_url1 + href;
  124. var url2 = mirror_url3 + href;
  125. var div1 = `<div class="user_download" style="display: flex;justify-content: flex-end;margin-left:9px"><div><a style="padding:4px;" class="btn user-btn-link" href="${url1}" rel="nofollow">快速下载1</a></div><div><a style="padding:4px" class="btn user-btn-link" href="${url2}" rel="nofollow">快速下载2(推荐)</a></div></div>`
  126. $(this).append(div1);
  127. });
  128. });
  129. // Fast download下载按钮
  130. $(".dropdown-menu .list-style-none li:last").each(function () {
  131. var url1 = mirror_url3 + "/" + a[3] + "/" + a[4] + "/archive/master.zip";
  132. var span1 = `<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}">Fast Download ZIP</a></li>`;
  133. $(this).after(span1);
  134. });
  135. // 复制按钮
  136. $("#button-copy1").on("click", function () {
  137. GM_setClipboard($("#clone_case_1").val())
  138. alert("复制成功")
  139. })
  140. $("#button-copy2").on("click", function () {
  141. GM_setClipboard($("#clone_case_2").val())
  142. alert("复制成功")
  143. })
  144. //页面跳转
  145. $("#quickView1").on("click", function () {
  146. window.location.href = web_url1
  147. });
  148. $("#quickView2").on("click", function () {
  149. window.location.href = web_url2
  150. })
  151. $("#quickView3").on("click", function () {
  152. window.location.href = web_url3
  153. })
  154. $("#quickView4").on("click", function () {
  155. window.location.href = web_url4
  156. })
  157. // 隐藏面板
  158. $("#mirror-btn").on("click", function () {
  159. if (!hide) {
  160. $("#collapse").hide();
  161. } else {
  162. $("#collapse").show();
  163. }
  164. hide = !hide;
  165. })
  166. function mirrorBtnEvent() {
  167. if (!GM_getValue('mirror')) {
  168. $("#collapse").hide()
  169. } else {
  170. $("#collapse").show();
  171. }
  172. }
  173. function menuHideMirrorCollapse() {
  174. GM_setValue('mirror', !GM_getValue('mirror'))
  175. mirrorBtnEvent()
  176. console.log(GM_getValue('mirror'))
  177. }
  178. function init() {
  179. mirrorBtnEvent()
  180. }
  181. // 注册菜单
  182. GM_registerMenuCommand(`[🔔Hide & Show Mirror DashBoard]`, menuHideMirrorCollapse)
  183. GM_registerMenuCommand(`[📢FeedBack]`, function () { window.GM_openInTab('https://gitee.com/Botme/UserScript/issues', { active: true, insert: true, setParent: true }); })
  184. // 初始化面板
  185. init()
  186. GM_addStyle(GM_getResourceText("gpp_css"));
  187. })();