|
1 | 1 | // ==UserScript== |
2 | 2 | // @name Github 增强 - 高速下载 |
3 | | -// @version 1.1.7 |
| 3 | +// @version 1.1.8 |
4 | 4 | // @author X.I.U |
5 | 5 | // @description 为 Github 的 Clone、Release、Raw、Code(ZIP) 添加高速下载 |
6 | 6 | // @match https://github.com/*/* |
|
210 | 210 |
|
211 | 211 | // 鼠标指向则显示 |
212 | 212 | var mouseOverHandler = function(evt){ |
213 | | - var elem = evt.currentTarget, |
214 | | - aElm = elem.querySelectorAll('.fileDownLink'); |
215 | | - aElm.forEach(el=>el.style.visibility = 'visible'); |
| 213 | + var elem = evt.currentTarget, |
| 214 | + aElm_new = elem.querySelectorAll('.fileDownLink'), |
| 215 | + aElm_now = elem.querySelectorAll('svg.octicon.octicon-file.text-gray-light'); |
| 216 | + aElm_new.forEach(el=>el.style.cssText = 'display: inline'); |
| 217 | + aElm_now.forEach(el=>el.style.cssText = 'display: none'); |
216 | 218 | }; |
217 | 219 |
|
218 | 220 | // 鼠标离开则隐藏 |
219 | 221 | var mouseOutHandler = function(evt){ |
220 | 222 | var elem = evt.currentTarget, |
221 | | - aElm = elem.querySelectorAll('.fileDownLink'); |
222 | | - aElm.forEach(el=>el.style.visibility = 'hidden'); |
| 223 | + aElm_new = elem.querySelectorAll('.fileDownLink'), |
| 224 | + aElm_now = elem.querySelectorAll('svg.octicon.octicon-file.text-gray-light'); |
| 225 | + aElm_new.forEach(el=>el.style.cssText = 'display: none'); |
| 226 | + aElm_now.forEach(el=>el.style.cssText = 'display: inline'); |
223 | 227 | }; |
224 | 228 |
|
225 | 229 | // 循环添加 |
226 | 230 | files.each(function(i,fileElm){ |
227 | 231 | var trElm = fileElm.parentNode.parentNode, |
228 | | - cntElm = trElm.querySelector('.css-truncate.css-truncate-target.d-block.width-fit a'), |
229 | | - Name = cntElm.innerText, |
230 | | - href = cntElm.attributes['href'].nodeValue.replace('https://github.com',''); |
| 232 | + cntElm_a = trElm.querySelector('.css-truncate.css-truncate-target.d-block.width-fit a'), |
| 233 | + cntElm_svg = trElm.querySelector('.mr-3.flex-shrink-0 svg.octicon.octicon-file.text-gray-light'), |
| 234 | + Name = cntElm_a.innerText, |
| 235 | + href = cntElm_a.attributes['href'].nodeValue.replace('https://github.com',''); |
231 | 236 | var href2 = href.replace('/blob/','/'), url, url_name, url_tip = ""; |
232 | 237 | switch(menu_raw_fast) |
233 | 238 | { |
|
250 | 255 | url_name = download_url5_name; |
251 | 256 | break; |
252 | 257 | } |
253 | | - var html1 = ` <a href="${url}" download="${Name}" target="_blank" class="fileDownLink" style="visibility: hidden;" title="「${url_name}」 [Alt + 左键] 或 [右键 - 另存为...] 下载文件。 注意:鼠标点击 [☁] 图标,而不是左侧的文件名! ${url_tip}提示:点击浏览器右上角 Tampermonkey 扩展图标 - [ ${menu_raw_fast} ] 加速源 (☁) - 点击切换。">${raw_svg}</a>`; |
254 | | - $(cntElm).after(html1); |
| 258 | + var html1 = ` <a href="${url}" download="${Name}" target="_blank" class="fileDownLink" style="display: none;" title="「${url_name}」 [Alt + 左键] 或 [右键 - 另存为...] 下载文件。 注意:鼠标点击 [☁] 图标,而不是左侧的文件名! ${url_tip}提示:点击浏览器右上角 Tampermonkey 扩展图标 - [ ${menu_raw_fast} ] 加速源 (☁) - 点击切换。">${raw_svg}</a>`; |
| 259 | + $(cntElm_svg).after(html1); |
255 | 260 | // 绑定鼠标事件 |
256 | 261 | trElm.onmouseover=mouseOverHandler; |
257 | 262 | trElm.onmouseout=mouseOutHandler; |
|
0 commit comments