From 5ab63a9cb39e38ce7eb22a754ad88136732fd3e1 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Thu, 20 Jan 2022 14:13:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20Release=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81;=20=E5=85=BC=E5=AE=B9=20=E6=88=91=E7=9A=84=20[?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=97=A0=E7=BC=9D=E7=BF=BB=E9=A1=B5]=20?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=EF=BC=88Release=20=E9=A1=B5=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GithubEnhanced-High-Speed-Download.user.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/GithubEnhanced-High-Speed-Download.user.js b/GithubEnhanced-High-Speed-Download.user.js index ec399b8..87809d7 100644 --- a/GithubEnhanced-High-Speed-Download.user.js +++ b/GithubEnhanced-High-Speed-Download.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Github 增强 - 高速下载 -// @version 1.7.5 +// @version 1.7.6 // @author X.I.U // @description 高速下载 Git Clone/SSH、Release、Raw、Code(ZIP) 等文件、项目列表单文件快捷下载 (☁) // @match *://github.com/* @@ -124,18 +124,22 @@ // 在浏览器返回/前进时重新添加 Raw 下载链接(☁)事件 // Tampermonkey v4.11 版本添加的 onurlchange 事件 grant,可以监控 pjax 等网页的 URL 变化 if (window.onurlchange === undefined) {addUrlChangeEvent();} - window.addEventListener('urlchange', function() {addRawDownLink_();}); + window.addEventListener('urlchange', function() { + addRawDownLink_(); + if (location.pathname.indexOf('/releases')) {addRelease();} + }); // Release function addRelease() { - let html = document.getElementsByClassName('Box-footer'); if (html.length == 0) return + let html = document.querySelectorAll('.Box-footer'); if (html.length == 0) return let divDisplay = ''; if (document.documentElement.clientWidth > 1000) {divDisplay = 'float: right;margin-top: -3px;margin-left: 8px;';}; // 调整小屏幕时的样式 - Array.from(html).forEach(function (current) { + for (const current of html) { + if (current.querySelector('.XIU2-RS')) continue current.querySelectorAll('li.Box-row > a').forEach(function (_this) { let href = _this.href.split(location.host), - url = '', _html = `
`; + url = '', _html = `
`; // 循环生成 HTML 标签 for (let i=0;i${download_url[i][1]}` } - _html += `
` - _this.insertAdjacentHTML('afterend', _html); + _this.insertAdjacentHTML('afterend', _html + '
'); }); - }); + } }