|
143 | 143 | if (menu_feedBack_ID) {GM_unregisterMenuCommand(menu_rawFast_ID); GM_unregisterMenuCommand(menu_rawDownLink_ID); GM_unregisterMenuCommand(menu_gitClone_ID); GM_unregisterMenuCommand(menu_feedBack_ID); menu_rawFast = GM_getValue('xiu2_menu_raw_fast');}
|
144 | 144 | // 避免在减少 raw 数组后,用户储存的数据大于数组而报错
|
145 | 145 | if (menu_rawFast > raw_url.length - 1) menu_rawFast = 0
|
146 |
| - 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();}, {title: "点击开关「项目列表单文件快捷下载 (☁)」功能"}); |
| 146 | + 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();}, {title: "点击开关「项目列表单文件快捷下载 (☁)」功能"}); |
147 | 147 | 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, {title: "点击切换「项目列表单文件快捷下载 (☁)」功能的加速源"});
|
148 |
| - 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 命令] 功能`, timeout: 3500, onclick: function(){location.reload();}});} else {GM_setValue('menu_gitClone', true); GM_notification({text: `已开启 [添加 git clone 命令] 功能`, timeout: 3500, onclick: function(){location.reload();}});}registerMenuCommand();}, {title: "点击开关「添加 git clone 命令」功能"}); |
149 |
| - 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});}, {title: "点击前往反馈问题或提出建议"}); |
| 148 | + 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 命令」功能`, timeout: 3500});} else {GM_setValue('menu_gitClone', true); GM_notification({text: `已开启「添加 git clone 命令」功能`, timeout: 3500});}registerMenuCommand();}, {title: "点击开关「添加 git clone 命令」功能"}); |
| 149 | + menu_feedBack_ID = GM_registerMenuCommand('💬 反馈问题 & 功能建议', function () {GM_openInTab('https://github.com/XIU2/UserScript/issues/new', {active: true,insert: true,setParent: true});GM_openInTab('https://greasyfork.org/zh-CN/scripts/412245/feedback', {active: true,insert: true,setParent: true});}, {title: "点击前往反馈问题或提出建议"}); |
150 | 150 | }
|
151 | 151 |
|
152 | 152 | // 切换加速源
|
|
285 | 285 | let html = target.querySelector('input[value^="https:"]');
|
286 | 286 | if (!html) return;
|
287 | 287 | if (!html.nextElementSibling) return false;
|
288 |
| - let href_split = html.value.split(location.host)[1], |
| 288 | + let href_split = html.value.replace(/https:\/\/[^/]+/, ''), |
289 | 289 | html_parent = '<div style="margin-top: 4px;" class="XIU2-GC ' + html.parentElement.className + '">',
|
290 | 290 | url = '', _html = '', _gitClone = '';
|
291 | 291 | html.nextElementSibling.hidden = true; // 隐藏右侧复制按钮
|
|
294 | 294 | let html_clone = html.cloneNode(true);
|
295 | 295 | for (let i=0;i<clone_url.length;i++) {
|
296 | 296 | if (clone_url[i][0] === 'https://gitclone.com') {
|
297 |
| - url = _gitClone + clone_url[i][0] + '/github.com' + href_split |
| 297 | + url = clone_url[i][0] + '/github.com' + href_split |
298 | 298 | } else {
|
299 |
| - url = _gitClone + clone_url[i][0] + href_split |
| 299 | + url = clone_url[i][0] + href_split |
300 | 300 | }
|
301 |
| - html_clone.title = `加速源:${clone_url[i][1]} (点击可直接复制)\n${clone_url[i][2].replaceAll(' ','\n')}` |
302 |
| - html_clone.setAttribute('value', url) |
| 301 | + html_clone.title = `${url}\n加速源:${clone_url[i][1]} (点击可直接复制)\n${clone_url[i][2].replaceAll(' ','\n')}` |
| 302 | + html_clone.setAttribute('value', _gitClone + url) |
303 | 303 | _html += html_parent + html_clone.outerHTML + '</div>'
|
304 | 304 | }
|
305 | 305 | html.parentElement.insertAdjacentHTML('afterend', _html);
|
|
319 | 319 | // 克隆原 Git Clone SSH 元素
|
320 | 320 | let html_clone = html.cloneNode(true);
|
321 | 321 | for (let i=0;i<clone_ssh_url.length;i++) {
|
322 |
| - url = _gitClone + clone_ssh_url[i][0] + href_split |
323 |
| - html_clone.title = `加速源:${clone_ssh_url[i][1]} (点击可直接复制)\n${clone_ssh_url[i][2].replaceAll(' ','\n')}` |
324 |
| - html_clone.setAttribute('value', url) |
| 322 | + url = clone_ssh_url[i][0] + href_split |
| 323 | + html_clone.title = `${url}\n加速源:${clone_ssh_url[i][1]} (点击可直接复制)\n${clone_ssh_url[i][2].replaceAll(' ','\n')}` |
| 324 | + html_clone.setAttribute('value', _gitClone + url) |
325 | 325 | _html += html_parent + html_clone.outerHTML + '</div>'
|
326 | 326 | }
|
327 | 327 | html.parentElement.insertAdjacentHTML('afterend', _html);
|
|
388 | 388 | }
|
389 | 389 |
|
390 | 390 | url_name = raw_url[menu_rawFast][1]; url_tip = raw_url[menu_rawFast][2];
|
391 |
| - fileElm.insertAdjacentHTML('afterend', `<a href="${url}?DS_DOWNLOAD" download="${Name}" target="_blank" rel="noreferrer noopener nofollow" class="fileDownLink" style="display: none;" title="「${url_name}」 左键点击下载文件(注意:鼠标点击 [☁] 图标进行下载,而不是文件名!) ${url_tip} 提示:点击页面右侧飘浮着的 TamperMonkey 扩展图标 - [ ${raw_url[menu_rawFast][1]} ] 加速源 (☁) 即可切换。">${svg[0]}</a>`); |
| 391 | + fileElm.insertAdjacentHTML('afterend', `<a href="${url}?DS_DOWNLOAD" download="${Name}" target="_blank" rel="noreferrer noopener nofollow" class="fileDownLink" style="display: none;" title="「${url_name}」 左键点击下载文件(注意:鼠标点击 [☁] 图标进行下载,而不是文件名!) ${url_tip} 提示:点击页面右侧飘浮着的 TamperMonkey 扩展图标中的菜单「 [${raw_url[menu_rawFast][1]}] 加速源 (☁) 」即可切换。">${svg[0]}</a>`); |
392 | 392 | // 绑定鼠标事件
|
393 | 393 | trElm.onmouseover = mouseOverHandler;
|
394 | 394 | trElm.onmouseout = mouseOutHandler;
|
|
0 commit comments