|
106 | 106 |
|
107 | 107 | // Release |
108 | 108 | function addRelease(){ |
109 | | - let original = document.getElementsByClassName('Box Box--condensed') |
110 | | - if (!original) return |
111 | | - Array.from(original).forEach(function (current) { |
112 | | - current.querySelectorAll('.d-flex.Box-body > a').forEach(function (current2) { |
113 | | - let href = current2.href, |
| 109 | + let html = document.getElementsByClassName('Box Box--condensed');if (!html) return |
| 110 | + Array.from(html).forEach(function (current) { |
| 111 | + current.querySelectorAll('.d-flex.Box-body > a').forEach(function (_this) { |
| 112 | + let href = _this.href, |
114 | 113 | url = [ |
115 | 114 | download_url[0][0] + '/https://github.com' + href, |
116 | 115 | download_url[1][0] + '/https://github.com' + href, |
|
119 | 118 | download_url[4][0] + '/https://github.com' + href, |
120 | 119 | download_url[5][0] + '/https://github.com' + href |
121 | 120 | ], |
122 | | - html = `<div style="display: flex;justify-content: flex-end;">`; |
| 121 | + _html = `<div style="display: flex;justify-content: flex-end;">`; |
123 | 122 | for (let i=0;i<url.length;i++) |
124 | 123 | { |
125 | | - html += `<a style="${style[0]}" class="btn" href="${url[i]}" rel="noreferrer noopener nofollow">${download_url[i][1]}</a>` |
| 124 | + _html += `<a style="${style[0]}" class="btn" href="${url[i]}" rel="noreferrer noopener nofollow">${download_url[i][1]}</a>` |
126 | 125 | } |
127 | | - html += `</div>` |
128 | | - current2.nextElementSibling.insertAdjacentHTML('afterend', html); |
| 126 | + _html += `</div>` |
| 127 | + _this.nextElementSibling.insertAdjacentHTML('afterend', _html); |
129 | 128 | }); |
130 | 129 | // 修改[文件大小]元素样式 |
131 | 130 | document.querySelectorAll('small.pl-2.color-text-secondary.flex-shrink-0').forEach(el=>{el.style.cssText='display: flex; justify-content: flex-end; flex-grow: 1; margin-right: 8px;'}); |
132 | 131 |
|
133 | 132 |
|
134 | 133 | // Source Code |
135 | | - current.querySelectorAll('.d-block.Box-body > a').forEach(function (current2) { |
136 | | - let href = current2.href, |
| 134 | + current.querySelectorAll('.d-block.Box-body > a').forEach(function (_this) { |
| 135 | + let href = _this.href, |
137 | 136 | url = [ |
138 | 137 | download_url[0][0] + '/https://github.com' + href, |
139 | 138 | download_url[1][0] + '/https://github.com' + href, |
|
142 | 141 | download_url[4][0] + '/https://github.com' + href, |
143 | 142 | download_url[5][0] + '/https://github.com' + href |
144 | 143 | ], |
145 | | - html = `<div style="display: flex;justify-content: flex-end;flex-grow: 1;">`; |
| 144 | + _html = `<div style="display: flex;justify-content: flex-end;flex-grow: 1;">`; |
146 | 145 | for (let i=0;i<url.length;i++) |
147 | 146 | { |
148 | | - html += `<a style="${style[0]}" class="btn" href="${url[i]}" rel="noreferrer noopener nofollow">${download_url[i][1]}</a>` |
| 147 | + _html += `<a style="${style[0]}" class="btn" href="${url[i]}" rel="noreferrer noopener nofollow">${download_url[i][1]}</a>` |
149 | 148 | } |
150 | | - html += `</div>` |
151 | | - current2.insertAdjacentHTML('afterend', html); |
| 149 | + _html += `</div>` |
| 150 | + _this.insertAdjacentHTML('afterend', _html); |
152 | 151 | }); |
153 | 152 | }); |
154 | 153 | // 修改 Source code 样式,使其和加速按钮并列一排 |
|
158 | 157 |
|
159 | 158 | // Download ZIP |
160 | 159 | function addDownloadZIP(){ |
161 | | - let original = document.querySelector('.dropdown-menu.dropdown-menu-sw.p-0 ul li:last-child'); |
162 | | - if (!original) return |
163 | | - let href = original.getElementsByTagName('a')[0].href, |
| 160 | + let html = document.querySelector('.dropdown-menu.dropdown-menu-sw.p-0 ul li:last-child');if (!html) return |
| 161 | + let href = html.getElementsByTagName('a')[0].href, |
164 | 162 | url = [ |
165 | 163 | download_url[0][0] + "/https://github.com" + href, |
166 | 164 | download_url[1][0] + "/https://github.com" + href, |
|
169 | 167 | download_url[4][0] + "/https://github.com" + href, |
170 | 168 | download_url[5][0] + '/https://github.com' + href |
171 | 169 | ], |
172 | | - html = ``; |
| 170 | + _html = ``; |
173 | 171 | for (let i=0;i<url.length;i++) |
174 | 172 | { |
175 | | - 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>` |
| 173 | + _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>` |
176 | 174 | } |
177 | | - original.insertAdjacentHTML('afterend', html); |
| 175 | + html.insertAdjacentHTML('afterend', _html); |
178 | 176 | } |
179 | 177 |
|
180 | 178 |
|
181 | 179 | // Git Clone |
182 | 180 | function addGitClone(){ |
183 | | - let original = document.querySelector('[role="tabpanel"] div.input-group'); |
184 | | - if (!original) return |
| 181 | + let html = document.querySelector('[role="tabpanel"] div.input-group');if (!html) return |
185 | 182 | let href_split = location.href.split("/"), |
186 | 183 | url = [ |
187 | 184 | clone_url[0][0] + "/" + href_split[3] + "/" + href_split[4] + ".git", |
188 | 185 | clone_url[1][0] + "/github.com/" + href_split[3] + "/" + href_split[4] + ".git", |
189 | 186 | clone_url[2][0] + "/" + href_split[3] + "/" + href_split[4] + ".git" |
190 | 187 | ], |
191 | | - html = ``; |
| 188 | + _html = ``; |
192 | 189 | for (let i=0;i<url.length;i++) |
193 | 190 | { |
194 | | - 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>` |
| 191 | + _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>` |
195 | 192 | } |
196 | | - original.insertAdjacentHTML('afterend', html); |
| 193 | + html.insertAdjacentHTML('afterend', _html); |
197 | 194 | } |
198 | 195 |
|
199 | 196 |
|
200 | 197 | // Raw |
201 | 198 | function addRawFile(){ |
202 | | - let original = document.getElementById('raw-url') |
203 | | - if (!original) return |
| 199 | + let html = document.getElementById('raw-url');if (!html) return |
204 | 200 | let href = location.href.replace('https://github.com',''), |
205 | 201 | href2 = href.replace('/blob/','/'), |
206 | 202 | url = [ |
|
209 | 205 | raw_url[3][0] + href2, |
210 | 206 | raw_url[4][0] + "/" + raw_url[0][0] + href2 |
211 | 207 | ], |
212 | | - html = ``; |
| 208 | + _html = ``; |
213 | 209 | for (let i=0;i<url.length;i++) |
214 | 210 | { |
215 | | - 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>` |
| 211 | + _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>` |
216 | 212 | } |
217 | | - original.insertAdjacentHTML('afterend', html); |
| 213 | + html.insertAdjacentHTML('afterend', _html); |
218 | 214 | } |
219 | 215 |
|
220 | 216 |
|
221 | 217 | // 添加 Raw 下载链接(☁) |
222 | 218 | function addRawDownLink(){ |
223 | 219 | // 如果不是项目文件页面,就返回 |
224 | | - let files = document.querySelectorAll('div.Box-row svg.octicon.octicon-file'); |
225 | | - if(files.length === 0) return; |
226 | | - let files1 = document.querySelectorAll('a.fileDownLink'); |
227 | | - if(files1.length > 0) return; |
| 220 | + let files = document.querySelectorAll('div.Box-row svg.octicon.octicon-file');if(files.length === 0) return; |
| 221 | + let files1 = document.querySelectorAll('a.fileDownLink');if(files1.length > 0) return; |
228 | 222 |
|
229 | 223 | // 鼠标指向则显示 |
230 | 224 | var mouseOverHandler = function(evt){ |
|
270 | 264 | url_tip = raw_url[menu_raw_fast][2]; |
271 | 265 | break; |
272 | 266 | } |
273 | | - let html = ` <a href="${url}" download="${Name}" target="_blank" rel="noreferrer noopener nofollow" class="fileDownLink" style="display: none;" title="「${url_name}」 [Alt + 左键] 或 [右键 - 另存为...] 下载文件。 注意:鼠标点击 [☁] 图标,而不是左侧的文件名! ${url_tip}提示:点击浏览器右上角 Tampermonkey 扩展图标 - [ ${raw_url[menu_raw_fast][1]} ] 加速源 (☁) 即可切换。">${svg[2]}</a>`; |
274 | | - cntElm_svg.insertAdjacentHTML('afterend', html); |
| 267 | + let _html = ` <a href="${url}" download="${Name}" target="_blank" rel="noreferrer noopener nofollow" class="fileDownLink" style="display: none;" title="「${url_name}」 [Alt + 左键] 或 [右键 - 另存为...] 下载文件。 注意:鼠标点击 [☁] 图标,而不是左侧的文件名! ${url_tip}提示:点击浏览器右上角 Tampermonkey 扩展图标 - [ ${raw_url[menu_raw_fast][1]} ] 加速源 (☁) 即可切换。">${svg[2]}</a>`; |
| 268 | + cntElm_svg.insertAdjacentHTML('afterend', _html); |
275 | 269 | // 绑定鼠标事件 |
276 | 270 | trElm.onmouseover = mouseOverHandler; |
277 | 271 | trElm.onmouseout = mouseOutHandler; |
|
281 | 275 |
|
282 | 276 | // 删除 Raw 快捷下载(☁) |
283 | 277 | function delRawDownLink(){ |
284 | | - let aElm = document.querySelectorAll('.fileDownLink'); |
285 | | - if(aElm.length === 0) return; |
| 278 | + let aElm = document.querySelectorAll('.fileDownLink');if(aElm.length === 0) return; |
286 | 279 | aElm.forEach(function(fileElm){ |
287 | 280 | fileElm.remove() |
288 | 281 | }) |
|
0 commit comments