MCPcopy Create free account
hub / github.com/XIU2/UserScript / addRelease

Function addRelease

GithubEnhanced-High-Speed-Download.user.js:232–254  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

230
231 // Release
232 function addRelease() {
233 let html = document.querySelectorAll('.Box-footer'); if (html.length == 0 || location.pathname.indexOf('/releases') == -1) return
234 let divDisplay = 'margin-left: -90px;', new_download_url = get_New_download_url();
235 if (document.documentElement.clientWidth > 755) {divDisplay = 'margin-top: -3px;margin-left: 8px;display: inherit;';}; // 调整小屏幕时的样式
236 html[0].appendChild(document.createElement('style')).textContent = '@media (min-width: 768px) {.Box-footer li.Box-row>div>span.color-fg-muted {min-width: 27px !important;}}';
237 for (const current of html) {
238 if (current.querySelector('.XIU2-RS')) continue
239 current.querySelectorAll('li.Box-row a').forEach(function (_this) {
240 let href = _this.href.split(location.host),
241 url = '', _html = `<div class="XIU2-RS" style="${divDisplay}">`;
242
243 for (let i=0;i<new_download_url.length;i++) {
244 if (new_download_url[i][3] !== undefined && url.indexOf('/archive/') !== -1) {
245 url = new_download_url[i][3] + href[1]
246 } else {
247 url = new_download_url[i][0] + href[1]
248 }
249 _html += `<a style="${style[0]}" class="btn" href="${url}" target="_blank" title="${new_download_url[i][2]}\n\n提示:如果不想要点击链接在前台打开空白新标签页(一闪而过影响体验),\n可以 [鼠标中键] 或 [Ctrl+鼠标左键] 点击加速链接即可在后台打开新标签页!" rel="noreferrer noopener nofollow">${new_download_url[i][1]}</a>`
250 }
251 _this.parentElement.nextElementSibling.insertAdjacentHTML('beforeend', _html + '</div>');
252 });
253 }
254 }
255
256
257 // Download ZIP

Callers 2

callbackFunction · 0.85

Calls 1

get_New_download_urlFunction · 0.85

Tested by

no test coverage detected