Skip to content

Commit 13c92ff

Browse files
committed
修复 Raw 单文件快捷下载功能失效的问题(Github 网页样式调整导致的)
1 parent 6da818d commit 13c92ff

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

GithubEnhanced-High-Speed-Download.user.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
// ==UserScript==
22
// @name Github 增强 - 高速下载
3-
// @version 1.4.0
3+
// @version 1.4.1
44
// @author X.I.U
55
// @description 高速下载 Git Clone、Release、Raw、Code(ZIP) 等文件、项目列表单文件快捷下载 (☁)
66
// @match *://github.com/*
77
// @match *://hub.fastgit.org/*
88
// @icon https://i.loli.net/2021/03/07/oUHPFSOTjKnkMzJ.png
99
// @require https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
10+
/* globals $ */
1011
// @grant GM_registerMenuCommand
1112
// @grant GM_unregisterMenuCommand
1213
// @grant GM_openInTab
@@ -120,9 +121,9 @@
120121
html = `<div style="display: flex;justify-content: flex-end;">`;
121122
for (let i=0;i<url.length;i++)
122123
{
123-
html = html + `<a style="${style[0]}" class="btn" href="${url[i]}" rel="noreferrer noopener nofollow">${download_url[i][1]}</a>`
124+
html += `<a style="${style[0]}" class="btn" href="${url[i]}" rel="noreferrer noopener nofollow">${download_url[i][1]}</a>`
124125
}
125-
html = html + `</div>`
126+
html += `</div>`
126127
$(this).next().after(html);
127128
});
128129
// 修改[文件大小]元素样式
@@ -143,9 +144,9 @@
143144
html = `<div style="display: flex;justify-content: flex-end;flex-grow: 1;">`;
144145
for (let i=0;i<url.length;i++)
145146
{
146-
html = html + `<a style="${style[0]}" class="btn" href="${url[i]}" rel="noreferrer noopener nofollow">${download_url[i][1]}</a>`
147+
html += `<a style="${style[0]}" class="btn" href="${url[i]}" rel="noreferrer noopener nofollow">${download_url[i][1]}</a>`
147148
}
148-
html = html + `</div>`
149+
html += `</div>`
149150
$(this).after(html);
150151
});
151152
});
@@ -169,7 +170,7 @@
169170
html = ``;
170171
for (let i=0;i<url.length;i++)
171172
{
172-
html = html + `<li class="Box-row Box-row--hover-gray p-0"><a class="d-flex flex-items-center text-gray-dark text-bold no-underline p-3" rel="noreferrer noopener nofollow" href="${url[i]}">${svg[0]}Download ZIP ${download_url[i][1]}</a></li>`
173+
html += `<li class="Box-row Box-row--hover-gray p-0"><a class="d-flex flex-items-center text-gray-dark text-bold no-underline p-3" rel="noreferrer noopener nofollow" href="${url[i]}">${svg[0]}Download ZIP ${download_url[i][1]}</a></li>`
173174
}
174175
$(this).after(html);
175176
});
@@ -188,7 +189,7 @@
188189
html = ``;
189190
for (let i=0;i<url.length;i++)
190191
{
191-
html = html + `<div class="input-group" style="margin-top: 4px;" title="加速源:${clone_url[i][1]} (点击可直接复制)"><input value="${url[i]}" aria-label="${url[i]}" type="text" class="form-control input-monospace input-sm bg-gray-light" data-autoselect="" readonly=""><div class="input-group-button"><clipboard-copy value="${url[i]}" aria-label="Copy to clipboard" class="btn btn-sm" tabindex="0" role="button">${svg[1]}</clipboard-copy></div></div>`
192+
html += `<div class="input-group" style="margin-top: 4px;" title="加速源:${clone_url[i][1]} (点击可直接复制)"><input value="${url[i]}" aria-label="${url[i]}" type="text" class="form-control input-monospace input-sm bg-gray-light" data-autoselect="" readonly=""><div class="input-group-button"><clipboard-copy value="${url[i]}" aria-label="Copy to clipboard" class="btn btn-sm" tabindex="0" role="button">${svg[1]}</clipboard-copy></div></div>`
192193
}
193194
$(this).after(html);
194195
});
@@ -209,7 +210,7 @@
209210
html = ``;
210211
for (let i=0;i<url.length;i++)
211212
{
212-
html = html + `<a href="${url[i]}" title="${raw_url[i+1][2]}" role="button" rel="noreferrer noopener nofollow" class="btn btn-sm BtnGroup-item">${raw_url[i+1][1]}</a>`
213+
html += `<a href="${url[i]}" title="${raw_url[i+1][2]}" role="button" rel="noreferrer noopener nofollow" class="btn btn-sm BtnGroup-item">${raw_url[i+1][1]}</a>`
213214
}
214215
$(this).after(html);
215216
});
@@ -228,7 +229,7 @@
228229
var mouseOverHandler = function(evt){
229230
let elem = evt.currentTarget,
230231
aElm_new = elem.querySelectorAll('.fileDownLink'),
231-
aElm_now = elem.querySelectorAll('svg.octicon.octicon-file.text-gray-light');
232+
aElm_now = elem.querySelectorAll('svg.octicon.octicon-file.color-icon-tertiary');
232233
aElm_new.forEach(el=>el.style.cssText = 'display: inline');
233234
aElm_now.forEach(el=>el.style.cssText = 'display: none');
234235
};
@@ -237,7 +238,7 @@
237238
var mouseOutHandler = function(evt){
238239
let elem = evt.currentTarget,
239240
aElm_new = elem.querySelectorAll('.fileDownLink'),
240-
aElm_now = elem.querySelectorAll('svg.octicon.octicon-file.text-gray-light');
241+
aElm_now = elem.querySelectorAll('svg.octicon.octicon-file.color-icon-tertiary');
241242
aElm_new.forEach(el=>el.style.cssText = 'display: none');
242243
aElm_now.forEach(el=>el.style.cssText = 'display: inline');
243244
};
@@ -246,10 +247,11 @@
246247
files.each(function(i,fileElm){
247248
let trElm = fileElm.parentNode.parentNode,
248249
cntElm_a = trElm.querySelector('.css-truncate.css-truncate-target.d-block.width-fit a'),
249-
cntElm_svg = trElm.querySelector('.mr-3.flex-shrink-0 svg.octicon.octicon-file.text-gray-light'),
250+
cntElm_svg = trElm.querySelector('.mr-3.flex-shrink-0 svg.octicon.octicon-file.color-icon-tertiary'),
250251
Name = cntElm_a.innerText,
251252
href = cntElm_a.attributes['href'].nodeValue.replace('https://github.com','');
252253
let href2 = href.replace('/blob/','/'), url, url_name, url_tip = '';
254+
console.log(cntElm_a, cntElm_svg, Name, href)
253255
switch(menu_raw_fast)
254256
{
255257
case 2:

0 commit comments

Comments
 (0)