diff --git a/packages/gui/extra/scripts/github.script b/packages/gui/extra/scripts/github.script index adb7ae6b..f8f83a13 100644 --- a/packages/gui/extra/scripts/github.script +++ b/packages/gui/extra/scripts/github.script @@ -123,9 +123,9 @@ '' ], style = ['padding:0 6px; margin-right: -1px; border-radius: 2px; background-color: var(--XIU2-back-Color); border-color: rgba(27, 31, 35, 0.1); font-size: 11px; color: var(--XIU2-font-Color);']; - if (menu_rawFast == null){menu_rawFast = 1; GM_setValue('xiu2_menu_raw_fast', 1)}; - if (GM_getValue('menu_rawDownLink') == null){GM_setValue('menu_rawDownLink', true)}; - if (GM_getValue('menu_gitClone') == null){GM_setValue('menu_gitClone', true)}; + if (menu_rawFast == null){menu_rawFast = 1; GM_setValue('xiu2_menu_raw_fast', 1)} + if (GM_getValue('menu_rawDownLink') == null){GM_setValue('menu_rawDownLink', true)} + if (GM_getValue('menu_gitClone') == null){GM_setValue('menu_gitClone', true)} registerMenuCommand(); // 注册脚本菜单 function registerMenuCommand() { @@ -134,8 +134,8 @@ // 避免在减少 raw 数组后,用户储存的数据大于数组而报错 if (menu_rawFast > raw_url.length - 1) menu_rawFast = 0 if (GM_getValue('menu_rawDownLink')) menu_rawFast_ID = GM_registerMenuCommand(`${['0️⃣','1️⃣','2️⃣','3️⃣','4️⃣','5️⃣','6️⃣','7️⃣','8️⃣','9️⃣','🔟'][menu_rawFast]} [ ${raw_url[menu_rawFast][1]} ] 加速源 (☁) - 点击切换`, menu_toggle_raw_fast); - menu_rawDownLink_ID = GM_registerMenuCommand(`${GM_getValue('menu_rawDownLink')?'✅':'❌'} 项目列表单文件快捷下载 (☁)`, function(){if (GM_getValue('menu_rawDownLink') == true) {GM_setValue('menu_rawDownLink', false); GM_notification({text: `已关闭 [项目列表单文件快捷下载 (☁)] 功能\n(点击刷新网页后生效)`, timeout: 3500, onclick: function(){location.reload();}});} else {GM_setValue('menu_rawDownLink', true); GM_notification({text: `已开启 [项目列表单文件快捷下载 (☁)] 功能\n(点击刷新网页后生效)`, timeout: 3500, onclick: function(){location.reload();}});}registerMenuCommand();}); - menu_gitClone_ID = GM_registerMenuCommand(`${GM_getValue('menu_gitClone')?'✅':'❌'} 添加 git clone 命令`, function(){if (GM_getValue('menu_gitClone') == true) {GM_setValue('menu_gitClone', false); GM_notification({text: `已关闭 [添加 git clone 命令] 功能\n(点击刷新网页后生效)`, timeout: 3500, onclick: function(){location.reload();}});} else {GM_setValue('menu_gitClone', true); GM_notification({text: `已开启 [添加 git clone 命令] 功能\n(点击刷新网页后生效)`, timeout: 3500, onclick: function(){location.reload();}});}registerMenuCommand();}); + menu_rawDownLink_ID = GM_registerMenuCommand(`${GM_getValue('menu_rawDownLink')?'✅':'❌'} 项目列表单文件快捷下载 (☁)`, function(){if (GM_getValue('menu_rawDownLink') === true) {GM_setValue('menu_rawDownLink', false); GM_notification({text: `已关闭 [项目列表单文件快捷下载 (☁)] 功能\n(点击刷新网页后生效)`, timeout: 3500, onclick: function(){location.reload();}});} else {GM_setValue('menu_rawDownLink', true); GM_notification({text: `已开启 [项目列表单文件快捷下载 (☁)] 功能\n(点击刷新网页后生效)`, timeout: 3500, onclick: function(){location.reload();}});}registerMenuCommand();}); + menu_gitClone_ID = GM_registerMenuCommand(`${GM_getValue('menu_gitClone')?'✅':'❌'} 添加 git clone 命令`, function(){if (GM_getValue('menu_gitClone') === true) {GM_setValue('menu_gitClone', false); GM_notification({text: `已关闭 [添加 git clone 命令] 功能\n(点击刷新网页后生效)`, timeout: 3500, onclick: function(){location.reload();}});} else {GM_setValue('menu_gitClone', true); GM_notification({text: `已开启 [添加 git clone 命令] 功能\n(点击刷新网页后生效)`, timeout: 3500, onclick: function(){location.reload();}});}registerMenuCommand();}); menu_feedBack_ID = GM_registerMenuCommand('💬 反馈 & 建议 [Github]', function () {GM_openInTab('https://github.com/XIU2/UserScript', {active: true,insert: true,setParent: true});GM_openInTab('https://greasyfork.org/zh-CN/scripts/412245/feedback', {active: true,insert: true,setParent: true});}); } @@ -148,7 +148,7 @@ addRawDownLink(); // 添加新加速源 GM_notification({text: "已切换加速源为:" + raw_url[menu_rawFast][1], timeout: 3000}); // 提示消息 registerMenuCommand(); // 重新注册脚本菜单 - }; + } colorMode(); // 适配白天/夜间主题模式 setTimeout(addRawFile, 1000); // Raw 加速 @@ -180,15 +180,15 @@ if (target.nodeType !== 1) return if (target.tagName === 'DIV' && target.parentElement.id === '__primerPortalRoot__') { addDownloadZIP(target); - addGitClone(target); - if (addGitCloneSSH(target)) return; - } else if (target.tagName === 'DIV' && target.className.indexOf('Box-sc-') != -1) { + if (addGitClone(target) === false) return; + if (addGitCloneSSH(target) === false) return; + } else if (target.tagName === 'DIV' && target.className.indexOf('Box-sc-') !== -1) { if (target.querySelector('input[value^="https:"]')) { addGitCloneClear('.XIU2-GCS'); - if (addGitClone(target)) return; + if (addGitClone(target) === false) return; } else if (target.querySelector('input[value^="git@"]')) { addGitCloneClear('.XIU2-GC'); - if (addGitCloneSSH(target)) return; + if (addGitCloneSSH(target) === false) return; } else if (target.querySelector('input[value^="gh "]')) { addGitCloneClear('.XIU2-GC, .XIU2-GCS'); } @@ -211,9 +211,10 @@ // Release function addRelease() { - let html = document.querySelectorAll('.Box-footer'); if (html.length == 0 || location.pathname.indexOf('/releases') == -1) return + let html = document.querySelectorAll('.Box-footer'); + if (html.length === 0 || location.pathname.indexOf('/releases') === -1) return; let divDisplay = 'margin-left: -90px;', new_download_url = get_New_download_url(); - if (document.documentElement.clientWidth > 755) {divDisplay = 'margin-top: -3px;margin-left: 8px;display: inherit;';}; // 调整小屏幕时的样式 + if (document.documentElement.clientWidth > 755) {divDisplay = 'margin-top: -3px;margin-left: 8px;display: inherit;';} // 调整小屏幕时的样式 for (const current of html) { if (current.querySelector('.XIU2-RS')) continue current.querySelectorAll('li.Box-row a').forEach(function (_this) { @@ -273,7 +274,7 @@ function addGitClone(target) { let html = target.querySelector('input[value^="https:"]'); if (!html) return; - if (!html.nextElementSibling) return true; + if (!html.nextElementSibling) return false; let href_split = html.value.split(location.host)[1], html_parent = '