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

Function addRawFile

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

Source from the content-addressed store, hash-verified

353
354 // Raw
355 function addRawFile() {
356 let html = document.querySelector('a[data-testid="raw-button"]');if (!html) return
357 let href = location.href.replace(`https://${location.host}`,''),
358 href2 = href.replace('/blob/','/'),
359 url = '', _html = '';
360
361 for (let i=1;i<raw_url.length;i++) {
362 if ((raw_url[i][0].indexOf('/gh') + 3 === raw_url[i][0].length) && raw_url[i][0].indexOf('cdn.staticaly.com') === -1) {
363 url = raw_url[i][0] + href.replace('/blob/','@');
364 } else {
365 url = raw_url[i][0] + href2;
366 }
367 _html += `<a href="${url}" title="${raw_url[i][2]}\n\n提示:如果想要直接下载,可使用 [Alt + 左键] 点击加速按钮或 [右键 - 另存为...]" target="_blank" role="button" rel="noreferrer noopener nofollow" data-size="small" data-variant="default" class="${html.className} XIU2-RF" style="border-radius: 0;margin-left: -1px;">${raw_url[i][1].replace(/ \d/,'')}</a>`
368 }
369 if (document.querySelector('.XIU2-RF')) document.querySelectorAll('.XIU2-RF').forEach((e)=>{e.remove()})
370 html.insertAdjacentHTML('afterend', _html);
371 }
372
373
374 // Raw 单文件快捷下载(☁)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected