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

Function directDownload

Lanzou-Enhanced.user.js:326–342  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

324
325 // 点击直接下载文件(分享链接列表页)
326 function directDownload() {
327 if (!menu_value('menu_directDownload')) return
328 if (document.getElementById('infos')) {
329 document.getElementById('infos').addEventListener('click', function(e) {
330 if (e.target.tagName === 'A') { // 针对普通样式的分享链接列表页
331 e.preventDefault(); // 阻止默认打开链接事件
332 GM_openInTab(e.target.href + '#download', {active: false, insert: true, setParent: true}); // 后台打开
333 } else { // 针对会员专属样式的分享链接列表页
334 const link = e.target.closest('a'); // 点击 <a> 元素的子元素时,寻找最近的 <a> 父元素
335 if ((link && this.contains(link))) {
336 e.preventDefault(); // 阻止默认打开链接事件
337 GM_openInTab(link.href + '#download', {active: false, insert: true, setParent: true}); // 后台打开
338 }
339 }
340 });
341 }
342 }
343 // 点击下载按钮
344 function directDownload_() {
345 if (!menu_value('menu_directDownload')) return

Callers 1

Calls 1

menu_valueFunction · 0.70

Tested by

no test coverage detected