diff --git a/GithubEnhanced-High-Speed-Download.user.js b/GithubEnhanced-High-Speed-Download.user.js index 8fb0fc1..36f8272 100644 --- a/GithubEnhanced-High-Speed-Download.user.js +++ b/GithubEnhanced-High-Speed-Download.user.js @@ -106,11 +106,10 @@ // Release function addRelease(){ - let original = document.getElementsByClassName('Box Box--condensed') - if (!original) return - Array.from(original).forEach(function (current) { - current.querySelectorAll('.d-flex.Box-body > a').forEach(function (current2) { - let href = current2.href, + let html = document.getElementsByClassName('Box Box--condensed');if (!html) return + Array.from(html).forEach(function (current) { + current.querySelectorAll('.d-flex.Box-body > a').forEach(function (_this) { + let href = _this.href, url = [ download_url[0][0] + '/https://github.com' + href, download_url[1][0] + '/https://github.com' + href, @@ -119,21 +118,21 @@ download_url[4][0] + '/https://github.com' + href, download_url[5][0] + '/https://github.com' + href ], - html = `
`; + _html = `
`; for (let i=0;i${download_url[i][1]}` + _html += `${download_url[i][1]}` } - html += `
` - current2.nextElementSibling.insertAdjacentHTML('afterend', html); + _html += `
` + _this.nextElementSibling.insertAdjacentHTML('afterend', _html); }); // 修改[文件大小]元素样式 document.querySelectorAll('small.pl-2.color-text-secondary.flex-shrink-0').forEach(el=>{el.style.cssText='display: flex; justify-content: flex-end; flex-grow: 1; margin-right: 8px;'}); // Source Code - current.querySelectorAll('.d-block.Box-body > a').forEach(function (current2) { - let href = current2.href, + current.querySelectorAll('.d-block.Box-body > a').forEach(function (_this) { + let href = _this.href, url = [ download_url[0][0] + '/https://github.com' + href, download_url[1][0] + '/https://github.com' + href, @@ -142,13 +141,13 @@ download_url[4][0] + '/https://github.com' + href, download_url[5][0] + '/https://github.com' + href ], - html = `
`; + _html = `
`; for (let i=0;i${download_url[i][1]}` + _html += `${download_url[i][1]}` } - html += `
` - current2.insertAdjacentHTML('afterend', html); + _html += `
` + _this.insertAdjacentHTML('afterend', _html); }); }); // 修改 Source code 样式,使其和加速按钮并列一排 @@ -158,9 +157,8 @@ // Download ZIP function addDownloadZIP(){ - let original = document.querySelector('.dropdown-menu.dropdown-menu-sw.p-0 ul li:last-child'); - if (!original) return - let href = original.getElementsByTagName('a')[0].href, + 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 = [ download_url[0][0] + "/https://github.com" + href, download_url[1][0] + "/https://github.com" + href, @@ -169,38 +167,36 @@ download_url[4][0] + "/https://github.com" + href, download_url[5][0] + '/https://github.com' + href ], - html = ``; + _html = ``; for (let i=0;i${svg[0]}Download ZIP ${download_url[i][1]}` + _html += `
  • ${svg[0]}Download ZIP ${download_url[i][1]}
  • ` } - original.insertAdjacentHTML('afterend', html); + html.insertAdjacentHTML('afterend', _html); } // Git Clone function addGitClone(){ - let original = document.querySelector('[role="tabpanel"] div.input-group'); - if (!original) return + let html = document.querySelector('[role="tabpanel"] div.input-group');if (!html) return let href_split = location.href.split("/"), url = [ clone_url[0][0] + "/" + href_split[3] + "/" + href_split[4] + ".git", clone_url[1][0] + "/github.com/" + href_split[3] + "/" + href_split[4] + ".git", clone_url[2][0] + "/" + href_split[3] + "/" + href_split[4] + ".git" ], - html = ``; + _html = ``; for (let i=0;i
    ${svg[1]}
    ` + _html += `
    ${svg[1]}
    ` } - original.insertAdjacentHTML('afterend', html); + html.insertAdjacentHTML('afterend', _html); } // Raw function addRawFile(){ - let original = document.getElementById('raw-url') - if (!original) return + let html = document.getElementById('raw-url');if (!html) return let href = location.href.replace('https://github.com',''), href2 = href.replace('/blob/','/'), url = [ @@ -209,22 +205,20 @@ raw_url[3][0] + href2, raw_url[4][0] + "/" + raw_url[0][0] + href2 ], - html = ``; + _html = ``; for (let i=0;i${raw_url[i+1][1]}` + _html += `${raw_url[i+1][1]}` } - original.insertAdjacentHTML('afterend', html); + html.insertAdjacentHTML('afterend', _html); } // 添加 Raw 下载链接(☁) function addRawDownLink(){ // 如果不是项目文件页面,就返回 - let files = document.querySelectorAll('div.Box-row svg.octicon.octicon-file'); - if(files.length === 0) return; - let files1 = document.querySelectorAll('a.fileDownLink'); - if(files1.length > 0) return; + let files = document.querySelectorAll('div.Box-row svg.octicon.octicon-file');if(files.length === 0) return; + let files1 = document.querySelectorAll('a.fileDownLink');if(files1.length > 0) return; // 鼠标指向则显示 var mouseOverHandler = function(evt){ @@ -270,8 +264,8 @@ url_tip = raw_url[menu_raw_fast][2]; break; } - let html = ` `; - cntElm_svg.insertAdjacentHTML('afterend', html); + let _html = ` `; + cntElm_svg.insertAdjacentHTML('afterend', _html); // 绑定鼠标事件 trElm.onmouseover = mouseOverHandler; trElm.onmouseout = mouseOutHandler; @@ -281,8 +275,7 @@ // 删除 Raw 快捷下载(☁) function delRawDownLink(){ - let aElm = document.querySelectorAll('.fileDownLink'); - if(aElm.length === 0) return; + let aElm = document.querySelectorAll('.fileDownLink');if(aElm.length === 0) return; aElm.forEach(function(fileElm){ fileElm.remove() }) diff --git a/Zhihu-Enhanced.user.js b/Zhihu-Enhanced.user.js index 2a9e431..25c68e0 100644 --- a/Zhihu-Enhanced.user.js +++ b/Zhihu-Enhanced.user.js @@ -7,7 +7,6 @@ // @match *://zhuanlan.zhihu.com/* // @icon https://static.zhihu.com/heifetz/favicon.ico // @require https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js -/* globals $ */ // @grant GM_registerMenuCommand // @grant GM_unregisterMenuCommand // @grant GM_openInTab