Skip to content

Commit fbf40e4

Browse files
committed
优化 match;修复 非项目文件列表页切换 Raw 加速源报错的问题
1 parent 1a71767 commit fbf40e4

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

GithubEnhanced-High-Speed-Download.user.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
// ==UserScript==
22
// @name Github 增强 - 高速下载
3-
// @version 1.2.5
3+
// @version 1.2.6
44
// @author X.I.U
55
// @description 高速下载 Clone、Release、Raw、Code(ZIP) 等文件、项目列表单文件快捷下载 (☁)
6-
// @match https://github.com/*/*
7-
// @match https://github.com/*/*/releases
8-
// @match https://github.com/*/*/releases/*
6+
// @match *://github.com/*
97
// @icon https://github.githubassets.com/favicon.ico
108
// @require https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
119
// @grant GM_registerMenuCommand
@@ -70,8 +68,8 @@
7068
menu_raw_fast += 1;
7169
}
7270
GM_setValue('xiu2_menu_raw_fast', menu_raw_fast);
73-
delDownLink(); // 删除旧加速源
74-
addDownLink(); // 添加新加速源
71+
delRawDownLink(); // 删除旧加速源
72+
addRawDownLink(); // 添加新加速源
7573
GM_notification(`已切换加速源为:${raw_url[menu_raw_fast][1]}`); // 提示消息
7674
registerMenuCommand(); // 重新注册脚本菜单
7775
};
@@ -80,14 +78,14 @@
8078
addDownloadZIP(); // Source Code 加速
8179
addGitClone(); // Download ZIP/Code(ZIP) 加速
8280
addRawFile(); // Raw 加速
83-
setTimeout(addDownLink, 2000); // 添加 Raw 下载链接(☁),延迟 2 秒执行,避免被 pjax 刷掉
81+
setTimeout(addRawDownLink, 2000); // 添加 Raw 下载链接(☁),延迟 2 秒执行,避免被 pjax 刷掉
8482

8583
document.addEventListener('pjax:success',function(){ // pjax 事件发生后
8684
addRelease(); // Release 加速
8785
addDownloadZIP(); // Source Code 加速
8886
addGitClone(); // Download ZIP/Code(ZIP) 加速
8987
addRawFile(); // 添加 Raw 加速按钮
90-
setTimeout(addDownLink, 2000); // 添加 Raw 下载链接(☁),延迟 2 秒执行,避免被 pjax 刷掉
88+
setTimeout(addRawDownLink, 2000); // 添加 Raw 下载链接(☁),延迟 2 秒执行,避免被 pjax 刷掉
9189
});
9290

9391

@@ -210,7 +208,7 @@
210208

211209

212210
// 添加 Raw 下载链接(☁)
213-
function addDownLink(){
211+
function addRawDownLink(){
214212
// 如果不是项目文件页面,就返回
215213
var files = $('div.Box-row svg.octicon.octicon-file');
216214
if(files.length === 0) return;
@@ -276,8 +274,9 @@
276274

277275

278276
// 删除 Raw 快捷下载(☁)
279-
function delDownLink(){
277+
function delRawDownLink(){
280278
var aElm = document.querySelectorAll('.fileDownLink');
279+
if(aElm.length === 0) return;
281280
for(var num = 0;num<aElm.length;num++){
282281
aElm[num].remove();
283282
};

0 commit comments

Comments
 (0)