From 84189b7154d242f2551751d378b5de4d04f3f7e1 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Mon, 16 Aug 2021 11:23:00 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=B2=B9=E7=8C=B4=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/gui/extra/scripts/github.script | 67 ++++++------------------ 1 file changed, 15 insertions(+), 52 deletions(-) diff --git a/packages/gui/extra/scripts/github.script b/packages/gui/extra/scripts/github.script index b2e8e6d9..1095009b 100644 --- a/packages/gui/extra/scripts/github.script +++ b/packages/gui/extra/scripts/github.script @@ -1,6 +1,6 @@ // ==UserScript== // @name Github 增强 - 高速下载 -// @version 1.5.6 +// @version 1.5.7 // @author X.I.U // @description 高速下载 Git Clone/SSH、Release、Raw、Code(ZIP) 等文件、项目列表单文件快捷下载 (☁) // @match *://github.com/* @@ -17,6 +17,7 @@ // @namespace https://greasyfork.org/scripts/412245 // @supportURL https://github.com/XIU2/UserScript // @homepageURL https://github.com/XIU2/UserScript +// @downloadURL none // ==/UserScript== (function() { @@ -29,7 +30,7 @@ fontColor = '#768390'; } else { backColor = '#161a21'; - fontColor = '#b2b8bf'; + fontColor = '#97a0aa'; } } else if (document.getElementsByTagName('html')[0].getAttribute('data-color-mode') === 'auto') { console.log(window.getComputedStyle(document.body).backgroundColor) @@ -38,13 +39,13 @@ fontColor = '#768390'; } else if (window.getComputedStyle(document.body).backgroundColor === 'rgb(13, 17, 23)') { backColor = '#161a21'; - fontColor = '#b2b8bf'; + fontColor = '#97a0aa'; } } //['https://gh.66ccff.work', '美国'], //['https://github.91chifun.workers.dev', '美国'], //['https://github.rc1844.workers.dev', '美国'], - var download_url = [ + const download_url = [ ['https://gh.api.99988866.xyz', '美国'], ['https://gh.msx.workers.dev', '美国'], ['https://gh.xiu2.xyz', '美国'], @@ -71,13 +72,12 @@ ['https://ghproxy.com','韩国首尔', ''] ], svg = [ - '', - '', + '', + '', '' ], - style = ['padding:0 6px;margin-right: -1px;border-radius: 2px;background-color: '+backColor+';border-color: rgba(27, 31, 35, 0.1);font-size: 11px;color: '+fontColor+';'], - menu_raw_fast = GM_getValue('xiu2_menu_raw_fast'), - menu_menu_raw_fast_ID, menu_feedBack_ID; + style = ['padding:0 6px;margin-right: -1px;border-radius: 2px;background-color: '+backColor+';border-color: rgba(27, 31, 35, 0.1);font-size: 11px;color: '+fontColor+';']; + var menu_raw_fast = GM_getValue('xiu2_menu_raw_fast'), menu_menu_raw_fast_ID, menu_feedBack_ID; if (menu_raw_fast == null){menu_raw_fast = 1; GM_setValue('xiu2_menu_raw_fast', 1)}; registerMenuCommand(); @@ -109,30 +109,9 @@ registerMenuCommand(); // 重新注册脚本菜单 }; + // 菜单数字图标 function menu_num(num) { - switch(num) { - case 0: - return '0️⃣' - break; - case 1: - return '1️⃣' - break; - case 2: - return '2️⃣' - break; - case 3: - return '3️⃣' - break; - case 4: - return '4️⃣' - break; - case 5: - return '5️⃣' - break; - case 6: - return '6️⃣' - break; - } + return ['0️⃣','1️⃣','2️⃣','3️⃣','4️⃣','5️⃣','6️⃣','7️⃣','8️⃣','9️⃣','🔟'][num] } addRelease(); // Release 加速 @@ -156,22 +135,6 @@ addRawDownLink_(); // 在浏览器返回/前进时重新添加 Raw 下载链接(☁)事件 }) - /*pushHistory(); - window.addEventListener('popstate', function(e) { - addRawDownLink_(); // 在浏览器返回/前进时重新添加 Raw 下载链接(☁)事件 - }, false); - function pushHistory() { - let state = {title: 'title',url: '#'}; - window.history.pushState(state, '', ''); - }*/ - - /*let oldUrl = location.href, - timer = setInterval(function(){ - if (oldUrl != location.href) { - oldUrl = location.href; - addRawDownLink_(); // 在浏览器返回/前进时重新添加 Raw 下载链接(☁)事件 - } - }, 1000);*/ // Release function addRelease() { @@ -251,7 +214,7 @@ } for (let i=0;i${svg[0]}Download ZIP ${download_url[i][1]}` + _html += `
  • ${svg[0]}Download ZIP ${download_url[i][1]}
  • ` } html.insertAdjacentHTML('afterend', _html); } @@ -273,7 +236,7 @@ } for (let i=0;i
    ${svg[1]}
    ` + _html += `
    ${svg[1]}
    ` } html.insertAdjacentHTML('afterend', _html); } @@ -293,7 +256,7 @@ } for (let i=0;i
    ${svg[1]}
    ` + _html += `
    ${svg[1]}
    ` } html.insertAdjacentHTML('afterend', _html); } @@ -424,7 +387,7 @@ } - // 自定义 locationchange 事件(用来监听 URL 变化,针对的是 Github 这种因为使用 pjax 而无法依靠 hashchange 监听的网页) + // 自定义 locationchange 事件(用来监听 URL 变化) function addLocationchange() { history.pushState = ( f => function pushState(){ var ret = f.apply(this, arguments);