复制github油猴脚本。

scripts
王良 2024-04-24 17:43:58 +08:00
parent 3ca9725dc2
commit e8613eaf45
2 changed files with 29 additions and 26 deletions

View File

@ -4,7 +4,7 @@
*
* @name Github 增强 - 高速下载Github油猴脚本
* @name:en Github Enhancement - High Speed DownloadGithub Greasemonkey Script
* @version 2.5.20.3
* @version 2.5.20_3
* @since 2024-04-24 17:38
* @author X.I.U
* @description 高速下载 Git Clone/SSHReleaseRawCode(ZIP) 等文件 (公益加速)项目列表单文件快捷下载 ()添加 git clone 命令
@ -15,7 +15,7 @@
* @homepageURL https://github.com/XIU2/UserScript
* @sourceURL https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js
*/
var ds_github_monkey_version = "2.5.20.3";
var ds_github_monkey_version = "2.5.20_3";
document.addEventListener("DOMContentLoaded", () => {
const DS_init = (window.__ds_global__ || {})['DS_init']
if (typeof DS_init === 'function') {

View File

@ -4,7 +4,8 @@
*
* @name Github 增强 - 高速下载Github油猴脚本
* @name:en Github Enhancement - High Speed DownloadGithub Greasemonkey Script
* @version 2.5.20
* @version 2.5.20_3
* @since 2024-04-24 17:38
* @author X.I.U
* @description 高速下载 Git Clone/SSHReleaseRawCode(ZIP) 等文件 (公益加速)项目列表单文件快捷下载 ()添加 git clone 命令
* @description:en High-speed download of Git Clone/SSH, Release, Raw, Code(ZIP) and other files (Based on public welfare), project list file quick download ()
@ -14,29 +15,31 @@
* @homepageURL https://github.com/XIU2/UserScript
* @sourceURL https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js
*/
var ds_github_monkey_version = "2.5.20_3";
document.addEventListener("DOMContentLoaded", () => {
const DS_init = (window.__ds_global__ || {})['DS_init']
if (typeof DS_init === 'function') {
console.log("ds_github_monkey_2.5.20: do DS_init")
DS_init({
const options = {
name: "Github 增强 - 高速下载",
icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAACEUExURUxpcRgWFhsYGBgWFhcWFh8WFhoYGBgWFiUlJRcVFRkWFhgVFRgWFhgVFRsWFhgWFigeHhkWFv////////////r6+h4eHv///xcVFfLx8SMhIUNCQpSTk/r6+jY0NCknJ97e3ru7u+fn51BOTsPCwqGgoISDg6empmpoaK2srNDQ0FhXV3eXcCcAAAAXdFJOUwCBIZXMGP70BuRH2Ze/LpIMUunHkpQR34sfygAAAVpJREFUOMt1U+magjAMDAVb5BDU3W25b9T1/d9vaYpQKDs/rF9nSNJkArDA9ezQZ8wPbc8FE6eAiQUsOO1o19JolFibKCdHGHC0IJezOMD5snx/yE+KOYYr42fPSufSZyazqDoseTPw4lGJNOu6LBXVUPBG3lqYAOv/5ZwnNUfUifzBt8gkgfgINmjxOpgqUA147QWNaocLniqq3QsSVbQHNp45N/BAwoYQz9oUJEiE4GMGfoBSMj5gjeWRIMMqleD/CAzUHFqTLyjOA5zjNnwa4UCEZ2YK3khEcBXHjVBtEFeIZ6+NxYbPqWp1DLKV42t6Ujn2ydyiPi9nX0TTNAkVVZ/gozsl6FbrktkwaVvL2TRK0C8Ca7Hck7f5OBT6FFbLATkL2ugV0tm0RLM9fedDvhWstl8Wp9AFDjFX7yOY/lJrv8AkYuz7fuP8dv9izCYH+x3/LBnj9fYPBTpJDNzX+7cAAAAASUVORK5CYII=",
width: 300
});
}
console.log(`ds_github_monkey_${ds_github_monkey_version}: do ds_tampermonkey.DS_init, options:`, options)
DS_init(options)
} else {
console.log("ds_github_2.5.20: has no DS_init")
}
if (!((window.__ds_global__ || {}).GM_getValue || (() => true))("ds_enabled", true)) {
console.log("ds_github_monkey_2.5.20: disabled")
console.log(`ds_github_monkey_${ds_github_monkey_version}: tampermonkey disabled`)
return
}
const GM_registerMenuCommand = (window.__ds_global__ || {})['GM_registerMenuCommand'] || (() => {});
const GM_unregisterMenuCommand = (window.__ds_global__ || {})['GM_unregisterMenuCommand'] || (() => {});
const GM_openInTab = (window.__ds_global__ || {})['GM_openInTab'] || (() => {});
const GM_getValue = (window.__ds_global__ || {})['GM_getValue'] || (() => {});
const GM_setValue = (window.__ds_global__ || {})['GM_setValue'] || (() => {});
const GM_registerMenuCommand = (window.__ds_global__ || {})['GM_registerMenuCommand'] || (() => {})
const GM_unregisterMenuCommand = (window.__ds_global__ || {})['GM_unregisterMenuCommand'] || (() => {})
const GM_openInTab = (window.__ds_global__ || {})['GM_openInTab'] || (() => {})
const GM_getValue = (window.__ds_global__ || {})['GM_getValue'] || (() => {})
const GM_setValue = (window.__ds_global__ || {})['GM_setValue'] || (() => {})
const GM_notification = (window.__ds_global__ || {})['GM_notification'] || (() => {});
(function() {
@ -150,10 +153,10 @@ document.addEventListener("DOMContentLoaded", () => {
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');}
// 避免在减少 raw 数组后,用户储存的数据大于数组而报错
if (menu_rawFast > raw_url.length - 1) menu_rawFast = 0
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: "点击开关「项目列表单文件快捷下载 (☁)」功能"});
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: "点击开关「项目列表单文件快捷下载 (☁)」功能"});
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: "点击切换「项目列表单文件快捷下载 (☁)」功能的加速源"});
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 命令」功能"});
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: "点击前往反馈问题或提出建议"});
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 命令」功能"});
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: "点击前往反馈问题或提出建议"});
}
// 切换加速源
@ -292,7 +295,7 @@ document.addEventListener("DOMContentLoaded", () => {
let html = target.querySelector('input[value^="https:"]');
if (!html) return;
if (!html.nextElementSibling) return false;
let href_split = html.value.split(location.host)[1],
let href_split = html.value.replace(/https:\/\/\w+.\w+/g, ''),
html_parent = '<div style="margin-top: 4px;" class="XIU2-GC ' + html.parentElement.className + '">',
url = '', _html = '', _gitClone = '';
html.nextElementSibling.hidden = true; // 隐藏右侧复制按钮
@ -301,12 +304,12 @@ document.addEventListener("DOMContentLoaded", () => {
let html_clone = html.cloneNode(true);
for (let i=0;i<clone_url.length;i++) {
if (clone_url[i][0] === 'https://gitclone.com') {
url = _gitClone + clone_url[i][0] + '/github.com' + href_split
url = clone_url[i][0] + '/github.com' + href_split
} else {
url = _gitClone + clone_url[i][0] + href_split
url = clone_url[i][0] + href_split
}
html_clone.title = `加速源:${clone_url[i][1]} (点击可直接复制)\n${clone_url[i][2].replaceAll('&#10;','\n')}`
html_clone.setAttribute('value', url)
html_clone.title = `${url}\n加速源:${clone_url[i][1]} (点击可直接复制)\n${clone_url[i][2].replaceAll('&#10;','\n')}`
html_clone.setAttribute('value', _gitClone + url)
_html += html_parent + html_clone.outerHTML + '</div>'
}
html.parentElement.insertAdjacentHTML('afterend', _html);
@ -326,9 +329,9 @@ document.addEventListener("DOMContentLoaded", () => {
// 克隆原 Git Clone SSH 元素
let html_clone = html.cloneNode(true);
for (let i=0;i<clone_ssh_url.length;i++) {
url = _gitClone + clone_ssh_url[i][0] + href_split
html_clone.title = `加速源:${clone_ssh_url[i][1]} (点击可直接复制)\n${clone_ssh_url[i][2].replaceAll('&#10;','\n')}`
html_clone.setAttribute('value', url)
url = clone_ssh_url[i][0] + href_split
html_clone.title = `${url}\n加速源:${clone_ssh_url[i][1]} (点击可直接复制)\n${clone_ssh_url[i][2].replaceAll('&#10;','\n')}`
html_clone.setAttribute('value', _gitClone + url)
_html += html_parent + html_clone.outerHTML + '</div>'
}
html.parentElement.insertAdjacentHTML('afterend', _html);
@ -395,7 +398,7 @@ document.addEventListener("DOMContentLoaded", () => {
}
url_name = raw_url[menu_rawFast][1]; url_tip = raw_url[menu_rawFast][2];
fileElm.insertAdjacentHTML('afterend', `<a href="${url}?DS_DOWNLOAD" download="${Name}" target="_blank" rel="noreferrer noopener nofollow" class="fileDownLink" style="display: none;" title="「${url_name}」&#10;&#10;左键点击下载文件(注意:鼠标点击 [☁] 图标进行下载,而不是文件名!)&#10;&#10;${url_tip}&#10;&#10;提示:点击页面右侧飘浮着的 TamperMonkey 扩展图标 - [ ${raw_url[menu_rawFast][1]} ] 加速源 (☁) 即可切换。">${svg[0]}</a>`);
fileElm.insertAdjacentHTML('afterend', `<a href="${url}?DS_DOWNLOAD" download="${Name}" target="_blank" rel="noreferrer noopener nofollow" class="fileDownLink" style="display: none;" title="「${url_name}」&#10;&#10;左键点击下载文件(注意:鼠标点击 [☁] 图标进行下载,而不是文件名!)&#10;&#10;${url_tip}&#10;&#10;提示:点击页面右侧飘浮着的 TamperMonkey 扩展图标中的菜单「 [${raw_url[menu_rawFast][1]}] 加速源 (☁) 即可切换。">${svg[0]}</a>`);
// 绑定鼠标事件
trElm.onmouseover = mouseOverHandler;
trElm.onmouseout = mouseOutHandler;
@ -492,6 +495,6 @@ document.addEventListener("DOMContentLoaded", () => {
});
}
})();
console.log("ds_github_monkey_2.5.20: completed")
console.log(`ds_github_monkey_${ds_github_monkey_version}: completed`)
})
console.log("ds_github_monkey_2.5.20: loaded")
console.log(`ds_github_monkey_${ds_github_monkey_version}: loaded`)