From c41f44981bde9ff5855590caca8cb9f319413bfb Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Sun, 19 Sep 2021 14:07:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=8A=A0=E9=80=9F=E4=B8=8B=E8=BD=BD=E6=8C=89=E9=92=AE=E5=A4=B1?= =?UTF-8?q?=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=88Github=20=E7=BD=91?= =?UTF-8?q?=E9=A1=B5=E5=8F=98=E5=8A=A8=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GithubEnhanced-High-Speed-Download.user.js | 37 ++++++++++++---------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/GithubEnhanced-High-Speed-Download.user.js b/GithubEnhanced-High-Speed-Download.user.js index ecbfd00..f00fea1 100644 --- a/GithubEnhanced-High-Speed-Download.user.js +++ b/GithubEnhanced-High-Speed-Download.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Github 增强 - 高速下载 -// @version 1.6.0 +// @version 1.6.1 // @author X.I.U // @description 高速下载 Git Clone/SSH、Release、Raw、Code(ZIP) 等文件、项目列表单文件快捷下载 (☁) // @match *://github.com/* @@ -110,19 +110,19 @@ return ['0️⃣','1️⃣','2️⃣','3️⃣','4️⃣','5️⃣','6️⃣','7️⃣','8️⃣','9️⃣','🔟'][num] } - addRelease(); // Release 加速 - addDownloadZIP(); // Download ZIP 加速 - addGitClone(); // Git Clone 加速 - addGitCloneSSH(); // Git Clone SSH 加速 - addRawFile(); // Raw 加速 + addRelease(); // Release 加速 + setTimeout(addDownloadZIP, 2000); // Download ZIP 加速 + setTimeout(addGitClone, 2000); // Git Clone 加速 + setTimeout(addGitCloneSSH, 2000); // Git Clone SSH 加速 + addRawFile(); // Raw 加速 setTimeout(addRawDownLink, 2000); // 添加 Raw 下载链接(☁),延迟 2 秒执行,避免被 pjax 刷掉 document.addEventListener('pjax:success',function(){ // pjax 事件发生后 - addRelease(); // Release 加速 - addDownloadZIP(); // Download ZIP 加速 - addGitClone(); // Git Clone 加速 - addGitCloneSSH(); // Git Clone SSH 加速 - addRawFile(); // Raw 加速 + addRelease(); // Release 加速 + setTimeout(addDownloadZIP, 2000); // Download ZIP 加速 + setTimeout(addGitClone, 2000); // Git Clone 加速 + setTimeout(addGitCloneSSH, 2000); // Git Clone SSH 加速 + addRawFile(); // Raw 加速 setTimeout(addRawDownLink, 2000); // 添加 Raw 下载链接(☁),延迟 2 秒执行,避免被 pjax 刷掉 }); @@ -195,6 +195,7 @@ // Download ZIP function addDownloadZIP() { + if (document.querySelector('.XIU2-DZ')) return let html = document.querySelector('.dropdown-menu.dropdown-menu-sw.p-0 ul li:last-child');if (!html) return let href = html.getElementsByTagName('a')[0].href, url = [], @@ -210,7 +211,7 @@ } for (let i=0;i${svg[0]}Download ZIP ${download_url[i][1]}` + _html += `
  • ${svg[0]}Download ZIP ${download_url[i][1]}
  • ` } html.insertAdjacentHTML('afterend', _html); } @@ -218,6 +219,7 @@ // Git Clone function addGitClone() { + if (document.querySelector('.XIU2-GC')) return let html = document.querySelector('[role="tabpanel"]:nth-child(2) div.input-group');if (!html) return let href_split = html.getElementsByTagName('input')[0].getAttribute('value').split(location.host), url = [], @@ -232,7 +234,7 @@ } for (let i=0;i
    ${svg[1]}
    ` + _html += `
    ${svg[1]}
    ` } html.insertAdjacentHTML('afterend', _html); } @@ -240,6 +242,7 @@ // Git Clone SSH function addGitCloneSSH() { + if (document.querySelector('.XIU2-GCS')) return let html = document.querySelector('[role="tabpanel"]:nth-child(3) div.input-group');if (!html) return let href_split = html.getElementsByTagName('input')[0].getAttribute('value').split(':'), url = [], @@ -252,7 +255,7 @@ } for (let i=0;i
    ${svg[1]}
    ` + _html += `
    ${svg[1]}
    ` } html.insertAdjacentHTML('afterend', _html); } @@ -260,6 +263,7 @@ // Raw function addRawFile() { + if (document.querySelector('.XIU2-RF')) return let html = document.getElementById('raw-url');if (!html) return let href = location.href.replace(`https://${location.host}`,''), href2 = href.replace('/blob/','/'), @@ -267,12 +271,11 @@ raw_url[1][0] + '/gh' + href.replace('/blob/','@'), raw_url[2][0] + href2, raw_url[3][0] + '/gh' + href.replace('/blob/','/'), - raw_url[4][0] + '/' + raw_url[0][0] + href2, - raw_url[5][0] + '/' + raw_url[0][0] + href2 + raw_url[4][0] + '/' + raw_url[0][0] + href2 ], _html = ``; for (let i=0;i${raw_url[i+1][1]}` + _html += `${raw_url[i+1][1]}` } html.insertAdjacentHTML('afterend', _html); }