Github访问增强 - 高速浏览及下载工具

GitHub极速访问浏览助手,解决GitHub无法访问和加速工具,GitHub上不去打不开的解决办法,高速下载Git Clone/SSH,Release,Raw,Code/Zip等文件、项目列表单文件快捷下载,添加git clone/commit命令

  1. // ==UserScript==
  2. // @name Github访问增强 - 高速浏览及下载工具
  3. // @name:zh-CN Github访问增强 - 高速浏览及下载工具
  4. // @name:zh-TW Github訪問增強 - 高速瀏覽及下載工具
  5. // @name:en Github access enhancement - high-speed browsing and downloading tool
  6. // @namespace via. github helper
  7. // @version 2.4.8
  8. // @description GitHub极速访问浏览助手,解决GitHub无法访问和加速工具,GitHub上不去打不开的解决办法,高速下载Git Clone/SSH,Release,Raw,Code/Zip等文件、项目列表单文件快捷下载,添加git clone/commit命令
  9. // @description:zh-CN GitHub极速访问浏览助手,解决GitHub无法访问和加速工具,GitHub上不去打不开的解决办法,高速下载Git Clone/SSH,Release,Raw,Code/Zip等文件、项目列表单文件快捷下载,添加git clone/commit命令
  10. // @description:zh-TW GitHub極速訪問瀏覽助手,解決GitHub無法訪問和加速工具,GitHub上不去打不開的解決辦法,高速下載Git Clone/SSH,Release,Raw,Code/Zip等文件、項目列表單文件快捷下載,添加git clone/commit命令
  11. // @description:en GitHub extremely fast access browsing assistant, solution to GitHub inaccessibility and acceleration tools, solution to GitHub not being able to open it, high-speed download of Git Clone/SSH, Release, Raw, Code/Zip and other files, project list list files quick download, add git clone/commit command
  12. // @author via. github helper
  13. // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAABZZJREFUeF7tmneoHVUQh7+ggsaOitgVRLD3+oeIipqosWAXxYK9gA3Bgl3BjsEuURQraMSuqAiCJmJv0YAoGGOJYu8R5ZOzj33r2d1z7973fHfvGzjsLXPmzPz2lDkzM4EBpwkDbj/jAIzPgAFHYHwJDPgEGN8Ey5bAUcAtYXa8DDwNzAjPfpg0uwA7ANsDmwSFTwSuLypfBsANwHERS98CHgam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zE1Zvr44oiVvfTrRwNE377ueeySZ/ZrKP0fyw0aLjaNnKd+mwVlb9+0/7DwfwwA6wQ9FtctgPB8qB6dPRqvsMEY5v6MWBXJ2kdrn7z9DlFZerwMBHdP6wjvbaDgSHYt28ijxsf2gLxygmAMYEpEY4MN1t4+N5LWJMrWUfP0sU2O9PG2e27xzWd8ZTMgL8frsOWousxFejYAYYHkx4kK94LNMlmz2RZHa/jqEaFfhFS/pbyllAKAnbcOIOxYIcvwuh7jS+E4zULdPg2pVbnTRbEaaOjctlh4Lh+M1nBrfquqUe8O+tbuV6kAZArqjFg9MlYTKdYB6rXekTrNOgUgkysAXqPHAhgvhiCsR9ywHT4FhG4ByMsWDIEw9LR+l1mmFF0zHv17Df0gGF4Wj0yS2QsAigMtG8JghsIExHiC/ribaL5lv9nfcnnvELGnLqtNo2cBps96RiMBQM+UGw1B4wCMBspjeYyBnwH/AAVKHEyJVbrIAAAAAElFTkSuQmCC
  15. // @require http://cdn.staticfile.org/jquery/1.12.1/jquery.min.js
  16. // @supportURL http://letsmain.com/github-access-master?utm_source=greasyfork-origin
  17. // @include *://github.com/*
  18. // @include *://*.github.com/*
  19. // @include *://hub.fgit.gq/*
  20. // @include *://kgithub.com/*
  21. // @include *://hub.fgit.ml/*
  22. // @include *://*.baidu.com/*
  23. // @include *://*.so.com/*
  24. // @include *://*.google.com/*
  25. // @include *://*.bing.com/*
  26. // @include *://*.yandex.com/*
  27. // @include *://*.sogou.com/*
  28. // @include *://*.sm.cn/*
  29. // @grant GM_getResourceURL
  30. // @grant GM_getResourceText
  31. // @grant GM_xmlhttpRequest
  32. // @grant GM_addStyle
  33. // @grant GM_openInTab
  34. // @grant unsafeWindow
  35. // @run-at document-idle
  36. // @grant GM_getValue
  37. // @grant GM_setValue
  38. // @grant GM_download
  39. // @grant GM_getResourceURL
  40. // @run-at document-start
  41. // @grant GM_setClipboard
  42. // @compatible Chrome
  43. // @compatible Safari
  44. // @compatible Edge
  45. // @compatible Firefox
  46. // @compatible Opera
  47. // @antifeature payment
  48. // @license GPL-3.0 License
  49. // ==/UserScript==
  50.  
  51. (function() {
  52. 'use strict';
  53.  
  54. //Style for the access and download buttons
  55. GM_addStyle(`
  56. .download-button {
  57. display: inline-block;
  58. padding: 10px;
  59. margin-right: 10px;
  60. background-color: #007bff;
  61. color: #fff;
  62. font-weight: bold;
  63. text-decoration: none;
  64. border-radius: 5px;
  65. cursor: pointer;
  66. }
  67. `);
  68.  
  69. // Extract GitHub repository name from URL
  70. function extractRepositoryName() {
  71. const urlParts = window.location.href.split('/');
  72. if (urlParts.length >= 5) {
  73. const username = urlParts[3];
  74. const repository = urlParts[4].split('?')[0];
  75. return `${username}/${repository}`;
  76. }
  77. return null;
  78. }
  79.  
  80. // Generate download buttons for the extracted repository
  81. function generateDownloadButtons(repository) {
  82. const buttonContainer = document.createElement('div');
  83. buttonContainer.style.marginTop = '20px';
  84.  
  85. const zipButton = createButton('Download ZIP', `https://github.com/${repository}/archive/refs/heads/main.zip`);
  86. const tarButton = createButton('Download TAR', `https://github.com/${repository}/archive/refs/heads/main.tar.gz`);
  87. const mirrorButton = createButton('GitHub Mirror', `https://github.com.cnpmjs.org/${repository}`);
  88.  
  89. buttonContainer.appendChild(zipButton);
  90. buttonContainer.appendChild(tarButton);
  91. buttonContainer.appendChild(mirrorButton);
  92.  
  93. const targetElement = document.querySelector('#repo-content-pjax-container');
  94. if (targetElement) {
  95. targetElement.insertBefore(buttonContainer, targetElement.firstChild);
  96. } else {
  97. document.body.appendChild(buttonContainer);
  98. }
  99. }
  100.  
  101. // Create a download button
  102. function createButton(text, link) {
  103. const button = document.createElement('a');
  104. button.className = 'download-button';
  105. button.href = link;
  106. button.target = '_blank';
  107. button.innerText = text;
  108. return button;
  109. }
  110.  
  111. // Get repository contents and build a tree structure
  112. function buildFileTree(repository) {
  113. const apiUrl = `https://api.github.com/repos/${repository}/git/trees/main?recursive=1`;
  114. fetch(apiUrl)
  115. .then(response => response.json())
  116. .then(data => {
  117. const tree = parseTreeData(data.tree);
  118. renderFileTree(tree);
  119. })
  120. .catch(error => {
  121. console.error('Error fetching repository contents:', error);
  122. });
  123. }
  124.  
  125. function addAccessHelperButton() {
  126. const button = document.createElement('a');
  127. button.target = '_blank';
  128. button.style.position = 'fixed';
  129. button.style.top = `${Math.floor(Math.random() * 81) + 180}px`;
  130. button.style.left = '0';
  131. button.style.color = '#ffffff';
  132. button.innerText = 'GitHub访问助手';
  133. button.style.backgroundColor = '#' + Math.floor(Math.random() * 16777215).toString(16);
  134. button.href = 'http://letsmain.com/github-access-master?utm_source=greasyfork-origin';
  135. button.style.padding = '10px';
  136. button.style.borderRadius = '5px';
  137. button.style.zIndex = '99999';
  138. document.body.appendChild(button);
  139. }
  140.  
  141. // Creating a MutationObserver listener
  142. const observer = new MutationObserver(function (mutations) {
  143. // Add button when page loading is complete
  144. addAccessHelperButton();
  145.  
  146. // Stop listening
  147. observer.disconnect();
  148. });
  149.  
  150. // Start listening for document changes
  151. observer.observe(document, {
  152. childList: true,
  153. subtree: true,
  154. attributes: false,
  155. characterData: false
  156. });
  157.  
  158. // Parse tree data and create a tree structure
  159. function parseTreeData(treeData) {
  160. const root = {
  161. name: '',
  162. type: 'folder',
  163. children: []
  164. };
  165. const folders = {};
  166.  
  167. for (const entry of treeData) {
  168. const path = entry.path;
  169. const type = entry.type;
  170.  
  171. const pathParts = path.split('/');
  172. var currentFolder
  173. currentFolder = root;
  174.  
  175. for (let i = 0; i < pathParts.length; i++) {
  176. const part = pathParts[i];
  177.  
  178. if (part === '') {
  179. continue;
  180. }
  181.  
  182. if (i === pathParts.length - 1) {
  183. // File
  184. currentFolder.children.push({
  185. name: part,
  186. type: type,
  187. url: `https://github.com/${repository}/blob/main/${path}`
  188. });
  189. } else {
  190. // Folder
  191. if (!folders.hasOwnProperty(part)) {
  192. const folder = {
  193. name: part,
  194. type: 'folder',
  195. children: []
  196. };
  197. folders[part] = folder;
  198. currentFolder.children.push(folder);
  199. }
  200. currentFolder = folders[part];
  201. }
  202. }
  203. }
  204.  
  205. return root;
  206. }
  207.  
  208. // Render the file tree
  209. function renderFileTree(tree) {
  210. const treeContainer = document.createElement('div');
  211. treeContainer.style.marginTop = '20px';
  212.  
  213. renderTreeNode(tree, treeContainer);
  214.  
  215. const targetElement = document.querySelector('#repo-content-pjax-container');
  216. if (targetElement) {
  217. targetElement.insertBefore(treeContainer, targetElement.firstChild);
  218. } else {
  219. document.body.appendChild(treeContainer);
  220. }
  221. }
  222.  
  223. // Render a tree node
  224. function renderTreeNode(node, container) {
  225. const item = document.createElement('div');
  226.  
  227. const name = document.createElement('span');
  228. name.innerText = node.name;
  229. item.appendChild(name);
  230.  
  231. if (node.type === 'folder') {
  232. item.classList.add('folder');
  233.  
  234. const children = document.createElement('div');
  235. children.classList.add('children');
  236.  
  237. for (const child of node.children) {
  238. renderTreeNode(child, children);
  239. }
  240.  
  241. item.appendChild(children);
  242. } else {
  243. item.classList.add('file');
  244.  
  245. const downloadButton = createButton('Download', node.url);
  246. item.appendChild(downloadButton);
  247. }
  248.  
  249. container.appendChild(item);
  250. }
  251.  
  252. // Call the functions
  253. const repositoryName = extractRepositoryName();
  254. if (repositoryName) {
  255. generateDownloadButtons(repositoryName);
  256. buildFileTree(repositoryName);
  257. }
  258.  
  259. })();
  260.  
  261.  
  262.  

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址