|
20 | 20 | (function() { |
21 | 21 | var backColor = '#ffffff'; |
22 | 22 | var fontColor = '#888888'; |
23 | | - if(document.getElementsByTagName('html')[0].getAttribute('data-color-mode') == 'dark'){ // 黑暗模式判断 |
24 | | - if(document.getElementsByTagName('html')[0].getAttribute('data-dark-theme') == 'dark_dimmed'){ |
| 23 | + if (document.getElementsByTagName('html')[0].getAttribute('data-color-mode') == 'dark') { // 黑暗模式判断 |
| 24 | + if (document.getElementsByTagName('html')[0].getAttribute('data-dark-theme') == 'dark_dimmed') { |
25 | 25 | backColor = '#272e37'; |
26 | 26 | fontColor = '#768390'; |
27 | | - }else{ |
| 27 | + } else { |
28 | 28 | backColor = '#161a21'; |
29 | 29 | fontColor = '#b2b8bf'; |
30 | 30 | } |
|
62 | 62 | registerMenuCommand(); |
63 | 63 | // 注册脚本菜单 |
64 | 64 | function registerMenuCommand() { |
65 | | - if (menu_feedBack_ID){ // 如果反馈菜单ID不是 null,则删除所有脚本菜单 |
| 65 | + if (menu_feedBack_ID) { // 如果反馈菜单ID不是 null,则删除所有脚本菜单 |
66 | 66 | GM_unregisterMenuCommand(menu_menu_raw_fast_ID); |
67 | 67 | GM_unregisterMenuCommand(menu_feedBack_ID); |
68 | 68 | menu_raw_fast = GM_getValue('xiu2_menu_raw_fast'); |
69 | 69 | } |
70 | | - if(menu_raw_fast > raw_url.length - 1){ // 避免在减少 raw 数组后,用户储存的数据大于数组而报错 |
| 70 | + if (menu_raw_fast > raw_url.length - 1) { // 避免在减少 raw 数组后,用户储存的数据大于数组而报错 |
71 | 71 | menu_raw_fast = 0 |
72 | 72 | } |
73 | 73 | menu_menu_raw_fast_ID = GM_registerMenuCommand(`🔄 [ ${raw_url[menu_raw_fast][1]} ] 加速源 (☁) - 点击切换`, menu_toggle_raw_fast); |
|
76 | 76 |
|
77 | 77 | // 切换加速源 |
78 | 78 | function menu_toggle_raw_fast() { |
79 | | - if (menu_raw_fast >= raw_url.length - 1){ // 如果当前加速源位置大于等于加速源总数,则改为第一个加速源,反之递增下一个加速源 |
| 79 | + if (menu_raw_fast >= raw_url.length - 1) { // 如果当前加速源位置大于等于加速源总数,则改为第一个加速源,反之递增下一个加速源 |
80 | 80 | menu_raw_fast = 0; |
81 | | - }else{ |
| 81 | + } else { |
82 | 82 | menu_raw_fast += 1; |
83 | 83 | } |
84 | 84 | GM_setValue('xiu2_menu_raw_fast', menu_raw_fast); |
|
113 | 113 |
|
114 | 114 |
|
115 | 115 | // Release |
116 | | - function addRelease(){ |
| 116 | + function addRelease() { |
117 | 117 | let html = document.getElementsByClassName('Box Box--condensed');if (!html) return |
118 | 118 | Array.from(html).forEach(function (current) { |
119 | 119 | current.querySelectorAll('.d-flex.Box-body > a').forEach(function (_this) { |
|
127 | 127 | download_url[5][0] + '/' + _this.href |
128 | 128 | ], |
129 | 129 | _html = `<div style="display: flex;justify-content: flex-end;">`; |
130 | | - for (let i=0;i<url.length;i++) |
131 | | - { |
| 130 | + for (let i=0;i<url.length;i++) { |
132 | 131 | _html += `<a style="${style[0]}" class="btn" href="${url[i]}" rel="noreferrer noopener nofollow">${download_url[i][1]}</a>` |
133 | 132 | } |
134 | 133 | _html += `</div>` |
|
150 | 149 | download_url[5][0] + '/' + _this.href |
151 | 150 | ], |
152 | 151 | _html = `<div style="display: flex;justify-content: flex-end;flex-grow: 1;">`; |
153 | | - for (let i=0;i<url.length;i++) |
154 | | - { |
| 152 | + for (let i=0;i<url.length;i++) { |
155 | 153 | _html += `<a style="${style[0]}" class="btn" href="${url[i]}" rel="noreferrer noopener nofollow">${download_url[i][1]}</a>` |
156 | 154 | } |
157 | 155 | _html += `</div>` |
|
164 | 162 |
|
165 | 163 |
|
166 | 164 | // Download ZIP |
167 | | - function addDownloadZIP(){ |
| 165 | + function addDownloadZIP() { |
168 | 166 | let html = document.querySelector('.dropdown-menu.dropdown-menu-sw.p-0 ul li:last-child');if (!html) return |
169 | 167 | let href = html.getElementsByTagName('a')[0].href, |
170 | 168 | url = [ |
|
176 | 174 | download_url[5][0] + '/' + href |
177 | 175 | ], |
178 | 176 | _html = ``; |
179 | | - for (let i=0;i<url.length;i++) |
180 | | - { |
| 177 | + for (let i=0;i<url.length;i++) { |
181 | 178 | _html += `<li class="Box-row Box-row--hover-gray p-0"><a class="d-flex flex-items-center color-text-primary text-bold no-underline p-3" rel="noreferrer noopener nofollow" href="${url[i]}">${svg[0]}Download ZIP ${download_url[i][1]}</a></li>` |
182 | 179 | } |
183 | 180 | html.insertAdjacentHTML('afterend', _html); |
184 | 181 | } |
185 | 182 |
|
186 | 183 |
|
187 | 184 | // Git Clone |
188 | | - function addGitClone(){ |
| 185 | + function addGitClone() { |
189 | 186 | let html = document.querySelector('[role="tabpanel"] div.input-group');if (!html) return |
190 | 187 | let href_split = html.querySelector('input').getAttribute('value').split('github.com'), |
191 | 188 | url = [ |
|
194 | 191 | clone_url[2][0] + href_split[1] |
195 | 192 | ], |
196 | 193 | _html = ``; |
197 | | - for (let i=0;i<url.length;i++) |
198 | | - { |
| 194 | + for (let i=0;i<url.length;i++) { |
199 | 195 | _html += `<div class="input-group" style="margin-top: 4px;" title="加速源:${clone_url[i][1]} (点击可直接复制)"><input value="${url[i]}" aria-label="${url[i]}" type="text" class="form-control input-monospace input-sm bg-gray-light" data-autoselect="" readonly=""><div class="input-group-button"><clipboard-copy value="${url[i]}" aria-label="Copy to clipboard" class="btn btn-sm" tabindex="0" role="button">${svg[1]}</clipboard-copy></div></div>` |
200 | 196 | } |
201 | 197 | html.insertAdjacentHTML('afterend', _html); |
202 | 198 | } |
203 | 199 |
|
204 | 200 |
|
205 | 201 | // Raw |
206 | | - function addRawFile(){ |
| 202 | + function addRawFile() { |
207 | 203 | let html = document.getElementById('raw-url');if (!html) return |
208 | 204 | let href = location.href.replace('https://github.com',''), |
209 | 205 | href2 = href.replace('/blob/','/'), |
|
213 | 209 | raw_url[3][0] + "/" + raw_url[0][0] + href2 |
214 | 210 | ], |
215 | 211 | _html = ``; |
216 | | - for (let i=0;i<url.length;i++) |
217 | | - { |
| 212 | + for (let i=0;i<url.length;i++) { |
218 | 213 | _html += `<a href="${url[i]}" title="${raw_url[i+1][2]}" role="button" rel="noreferrer noopener nofollow" class="btn btn-sm BtnGroup-item">${raw_url[i+1][1]}</a>` |
219 | 214 | } |
220 | 215 | html.insertAdjacentHTML('afterend', _html); |
221 | 216 | } |
222 | 217 |
|
223 | 218 |
|
224 | 219 | // 添加 Raw 下载链接(☁) |
225 | | - function addRawDownLink(){ |
| 220 | + function addRawDownLink() { |
226 | 221 | // 如果不是项目文件页面,就返回,如果网页有 Raw 下载链接(☁)就返回 |
227 | 222 | let files = document.querySelectorAll('div.Box-row svg.octicon.octicon-file');if(files.length === 0) return; |
228 | 223 | let files1 = document.querySelectorAll('a.fileDownLink');if(files1.length > 0) return; |
229 | 224 |
|
230 | 225 | // 鼠标指向则显示 |
231 | | - var mouseOverHandler = function(evt){ |
| 226 | + var mouseOverHandler = function(evt) { |
232 | 227 | let elem = evt.currentTarget, |
233 | 228 | aElm_new = elem.querySelectorAll('.fileDownLink'), |
234 | 229 | aElm_now = elem.querySelectorAll('svg.octicon.octicon-file.color-icon-tertiary'); |
|
237 | 232 | }; |
238 | 233 |
|
239 | 234 | // 鼠标离开则隐藏 |
240 | | - var mouseOutHandler = function(evt){ |
| 235 | + var mouseOutHandler = function(evt) { |
241 | 236 | let elem = evt.currentTarget, |
242 | 237 | aElm_new = elem.querySelectorAll('.fileDownLink'), |
243 | 238 | aElm_now = elem.querySelectorAll('svg.octicon.octicon-file.color-icon-tertiary'); |
|
246 | 241 | }; |
247 | 242 |
|
248 | 243 | // 循环添加 |
249 | | - files.forEach(function(fileElm, i){ |
| 244 | + files.forEach(function(fileElm, i) { |
250 | 245 | let trElm = fileElm.parentNode.parentNode, |
251 | 246 | cntElm_a = trElm.querySelector('.css-truncate.css-truncate-target.d-block.width-fit a'), |
252 | 247 | cntElm_svg = trElm.querySelector('.mr-3.flex-shrink-0 svg.octicon.octicon-file.color-icon-tertiary'), |
|
280 | 275 |
|
281 | 276 |
|
282 | 277 | // 删除 Raw 快捷下载(☁) |
283 | | - function delRawDownLink(){ |
| 278 | + function delRawDownLink() { |
284 | 279 | let aElm = document.querySelectorAll('.fileDownLink');if(aElm.length === 0) return; |
285 | | - aElm.forEach(function(fileElm){ |
| 280 | + aElm.forEach(function(fileElm) { |
286 | 281 | fileElm.remove() |
287 | 282 | }) |
288 | 283 | } |
289 | 284 |
|
290 | 285 |
|
291 | 286 | // 在浏览器返回/前进时重新添加 Raw 下载链接(☁)鼠标事件 |
292 | | - function addRawDownLink_(){ |
| 287 | + function addRawDownLink_() { |
293 | 288 | // 如果不是项目文件页面,就返回,如果网页没有 Raw 下载链接(☁)就返回 |
294 | 289 | let files = document.querySelectorAll('div.Box-row svg.octicon.octicon-file');if(files.length === 0) return; |
295 | 290 | let files1 = document.querySelectorAll('a.fileDownLink');if(files1.length === 0) return; |
296 | 291 |
|
297 | 292 | // 鼠标指向则显示 |
298 | | - var mouseOverHandler = function(evt){ |
| 293 | + var mouseOverHandler = function(evt) { |
299 | 294 | let elem = evt.currentTarget, |
300 | 295 | aElm_new = elem.querySelectorAll('.fileDownLink'), |
301 | 296 | aElm_now = elem.querySelectorAll('svg.octicon.octicon-file.color-icon-tertiary'); |
|
304 | 299 | }; |
305 | 300 |
|
306 | 301 | // 鼠标离开则隐藏 |
307 | | - var mouseOutHandler = function(evt){ |
| 302 | + var mouseOutHandler = function(evt) { |
308 | 303 | let elem = evt.currentTarget, |
309 | 304 | aElm_new = elem.querySelectorAll('.fileDownLink'), |
310 | 305 | aElm_now = elem.querySelectorAll('svg.octicon.octicon-file.color-icon-tertiary'); |
|
313 | 308 | }; |
314 | 309 |
|
315 | 310 | // 循环添加 |
316 | | - files.forEach(function(fileElm, i){ |
| 311 | + files.forEach(function(fileElm, i) { |
317 | 312 | let trElm = fileElm.parentNode.parentNode; |
318 | 313 | // 绑定鼠标事件 |
319 | 314 | trElm.onmouseover = mouseOverHandler; |
|
0 commit comments