|
3 | 3 | // @name:en Github Enhancement - High Speed Download |
4 | 4 | // @name:zh-CN Github 增强 - 高速下载 |
5 | 5 | // @name:zh-TW Github 增強 - 高速下載 |
6 | | -// @version 1.8.3 |
| 6 | +// @version 1.8.4 |
7 | 7 | // @author X.I.U |
8 | 8 | // @description 高速下载 Git Clone/SSH、Release、Raw、Code(ZIP) 等文件、项目列表单文件快捷下载 (☁) |
9 | 9 | // @description:en High-speed download of Git Clone/SSH, Release, Raw, Code(ZIP) and other files, project list file quick download (☁) |
|
28 | 28 |
|
29 | 29 | (function() { |
30 | 30 | 'use strict'; |
31 | | - var backColor = '#ffffff', fontColor = '#888888'; |
32 | | - if (document.getElementsByTagName('html')[0].getAttribute('data-color-mode') === 'dark') { // 黑暗模式判断 |
33 | | - if (document.getElementsByTagName('html')[0].getAttribute('data-dark-theme') === 'dark_dimmed') { |
34 | | - backColor = '#272e37'; fontColor = '#768390'; |
35 | | - } else { |
36 | | - backColor = '#161a21'; fontColor = '#97a0aa'; |
37 | | - } |
38 | | - } else if (document.getElementsByTagName('html')[0].getAttribute('data-color-mode') === 'auto') { |
39 | | - if (window.getComputedStyle(document.body).backgroundColor === 'rgb(34, 39, 46)') { |
40 | | - backColor = '#272e37'; fontColor = '#768390'; |
41 | | - } else if (window.getComputedStyle(document.body).backgroundColor === 'rgb(13, 17, 23)') { |
42 | | - backColor = '#161a21'; fontColor = '#97a0aa'; |
43 | | - } |
44 | | - } |
| 31 | + var backColor = '#ffffff', fontColor = '#888888', menu_raw_fast = GM_getValue('xiu2_menu_raw_fast'), menu_menu_raw_fast_ID, menu_feedBack_ID; |
45 | 32 | const download_url = [ |
46 | 33 | ['https://pd.zwc365.com/seturl/https://github.com', '美国 1'], |
47 | 34 | ['https://gh.xiu.workers.dev/https://github.com', '美国 2'], |
|
52 | 39 | ['https://download.fastgit.org', '日本'], |
53 | 40 | ['https://ghproxy.com/https://github.com', '韩国'] |
54 | 41 | //['https://ghproxy.fsou.cc/https://github.com', '香港'] |
55 | | - ], |
| 42 | + ], |
56 | 43 | clone_url = [ |
57 | 44 | ['https://gitclone.com', '中国浙江'], |
58 | 45 | ['https://ghp.lvmhsh.cn.cnpmjs.org', '新加坡'], |
|
79 | 66 | '<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-copy js-clipboard-copy-icon d-inline-block"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check js-clipboard-check-icon color-fg-success d-inline-block d-sm-none"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg>', |
80 | 67 | '<svg class="octicon octicon-cloud-download" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M9 12h2l-3 3-3-3h2V7h2v5zm3-8c0-.44-.91-3-4.5-3C5.08 1 3 2.92 3 5 1.02 5 0 6.52 0 8c0 1.53 1 3 3 3h3V9.7H3C1.38 9.7 1.3 8.28 1.3 8c0-.17.05-1.7 1.7-1.7h1.3V5c0-1.39 1.56-2.7 3.2-2.7 2.55 0 3.13 1.55 3.2 1.8v1.2H12c.81 0 2.7.22 2.7 2.2 0 2.09-2.25 2.2-2.7 2.2h-2V11h2c2.08 0 4-1.16 4-3.5C16 5.06 14.08 4 12 4z"></path></svg>' |
81 | 68 | ], |
82 | | - 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+';']; |
83 | | - var menu_raw_fast = GM_getValue('xiu2_menu_raw_fast'), menu_menu_raw_fast_ID, menu_feedBack_ID; |
84 | | - if (menu_raw_fast == null){menu_raw_fast = 1; GM_setValue('xiu2_menu_raw_fast', 1)}; |
| 69 | + 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);']; |
85 | 70 |
|
| 71 | + if (menu_raw_fast == null){menu_raw_fast = 1; GM_setValue('xiu2_menu_raw_fast', 1)}; |
86 | 72 | registerMenuCommand(); |
87 | 73 | // 注册脚本菜单 |
88 | 74 | function registerMenuCommand() { |
|
117 | 103 | return ['0️⃣','1️⃣','2️⃣','3️⃣','4️⃣','5️⃣','6️⃣','7️⃣','8️⃣','9️⃣','🔟'][num] |
118 | 104 | } |
119 | 105 |
|
| 106 | + colorMode(); |
120 | 107 | addRelease(); // Release 加速 |
121 | 108 | setTimeout(addDownloadZIP, 2000); // Download ZIP 加速 |
122 | 109 | setTimeout(addGitClone, 2000); // Git Clone 加速 |
|
125 | 112 | setTimeout(addRawDownLink, 2000); // 添加 Raw 下载链接(☁),延迟 2 秒执行,避免被 pjax 刷掉 |
126 | 113 |
|
127 | 114 | document.addEventListener('pjax:success',function(){ // pjax 事件发生后 |
| 115 | + colorMode(); |
128 | 116 | addRelease(); // Release 加速 |
129 | 117 | setTimeout(addDownloadZIP, 2000); // Download ZIP 加速 |
130 | 118 | setTimeout(addGitClone, 2000); // Git Clone 加速 |
|
340 | 328 | } |
341 | 329 |
|
342 | 330 |
|
| 331 | + // 适配白天/夜间主题模式 |
| 332 | + function colorMode() { |
| 333 | + let style_Add; |
| 334 | + if (document.getElementById('XIU2-Github')) {style_Add = document.getElementById('XIU2-Github')} else {style_Add = document.createElement('style'); style_Add.id = 'XIU2-Github'; style_Add.type = 'text/css';} |
| 335 | + backColor = '#ffffff'; fontColor = '#888888'; |
| 336 | + |
| 337 | + if (document.getElementsByTagName('html')[0].getAttribute('data-color-mode') === 'dark') { // 如果是夜间模式 |
| 338 | + if (document.getElementsByTagName('html')[0].getAttribute('data-dark-theme') === 'dark_dimmed') { |
| 339 | + backColor = '#272e37'; fontColor = '#768390'; |
| 340 | + } else { |
| 341 | + backColor = '#161a21'; fontColor = '#97a0aa'; |
| 342 | + } |
| 343 | + } else if (document.getElementsByTagName('html')[0].getAttribute('data-color-mode') === 'auto') { // 如果是自动模式 |
| 344 | + if (window.matchMedia('(prefers-color-scheme: dark)').matches || document.getElementsByTagName('html')[0].getAttribute('data-light-theme').indexOf('dark') > -1) { // 如果浏览器是夜间模式 或 白天模式是 dark 的情况 |
| 345 | + if (document.getElementsByTagName('html')[0].getAttribute('data-dark-theme') === 'dark_dimmed') { |
| 346 | + backColor = '#272e37'; fontColor = '#768390'; |
| 347 | + } else if (document.getElementsByTagName('html')[0].getAttribute('data-dark-theme').indexOf('light') == -1) { // 排除夜间模式是 light 的情况 |
| 348 | + backColor = '#161a21'; fontColor = '#97a0aa'; |
| 349 | + } |
| 350 | + } |
| 351 | + } |
| 352 | + |
| 353 | + document.lastElementChild.appendChild(style_Add).textContent = `.XIU2-RS a {--XIU2-back-Color: ${backColor}; --XIU2-font-Color: ${fontColor};}`; |
| 354 | + } |
| 355 | + |
| 356 | + |
343 | 357 | // 自定义 urlchange 事件(用来监听 URL 变化) |
344 | 358 | function addUrlChangeEvent() { |
345 | 359 | history.pushState = ( f => function pushState(){ |
|
0 commit comments