Skip to content

Commit 57ece7a

Browse files
committed
修复 部分情况下可能出现的 Code/ZIP 加速源不显示的问题
1 parent 59f19bc commit 57ece7a

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

GithubEnhanced-High-Speed-Download.user.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// @name:zh-CN Github 增强 - 高速下载
44
// @name:zh-TW Github 增強 - 高速下載
55
// @name:ru Улучшение GitHub – быстрое скачивание
6-
// @version 2.6.36
6+
// @version 2.6.37
77
// @author X.I.U
88
// @description High-speed download of Git Clone/SSH, Release, Raw, Code(ZIP) and other files (Based on public welfare), project list file quick download (☁)
99
// @description:zh-CN 高速下载 Git Clone/SSH、Release、Raw、Code(ZIP) 等文件 (公益加速)、项目列表单文件快捷下载 (☁)
@@ -264,9 +264,10 @@
264264
for (const target of mutation.addedNodes) {
265265
if (target.nodeType !== 1) return
266266
if (target.tagName === 'DIV' && target.parentElement && target.parentElement.id === '__primerPortalRoot__') {
267-
addDownloadZIP(target);
268267
addGitClone(target);
269268
addGitCloneSSH(target);
269+
addDownloadZIP(target);
270+
//setTimeout(()=>{addDownloadZIP(target)}, 300);
270271
} else if (target.tagName === 'DIV' && target.className.indexOf('LocalTab-module__') != -1) {
271272
if (target.querySelector('input[value^="https:"]')) {
272273
addGitCloneClear('.XIU2-GCS'); addGitClone(target);
@@ -325,11 +326,14 @@
325326

326327
// Download ZIP
327328
function addDownloadZIP(target) {
328-
let html = target.querySelector('ul[class^=prc-ActionList-ActionList-]>li:last-child');if (!html) return
329-
let href_script = document.querySelector('react-partial[partial-name=repos-overview]>script[data-target="react-partial.embeddedData"]'),
330-
href_slice = href_script.textContent.slice(href_script.textContent.indexOf('"zipballUrl":"')+14),
331-
href = href_slice.slice(0, href_slice.indexOf('"')),
332-
url = '', _html = '', new_download_url = get_New_download_url();
329+
const html = target.querySelector('ul[class^=prc-ActionList-ActionList-]>li:last-child');if (!html) return
330+
let href = html.querySelector('a[href^="/"][href$=".zip"]');if (!href || !href.getAttribute('href')) return
331+
href = href.getAttribute('href');
332+
//const href_script = document.querySelector('react-partial[partial-name=repos-overview]>script[data-target="react-partial.embeddedData"]');if (!href_script) return
333+
//const href = JSON.parse(href_script.textContent).props.initialPayload.overview.codeButton.local.platformInfo.zipballUrl
334+
/*let href_slice = href_script.textContent.slice(href_script.textContent.indexOf('"zipballUrl":"')+14),
335+
href = href_slice.slice(0, href_slice.indexOf('"')),*/
336+
let url = '', _html = '', new_download_url = get_New_download_url();
333337

334338
// 克隆原 Download ZIP 元素,并定位 <a> <span> 标签
335339
let html_clone = html.cloneNode(true),

0 commit comments

Comments
 (0)