Skip to content

Commit

Permalink
feat: support right click to download link
Browse files Browse the repository at this point in the history
  • Loading branch information
IronKinoko committed Jun 17, 2021
1 parent 69c39d2 commit 4c7e459
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
10 changes: 7 additions & 3 deletions src/agefans/getAllVideoURL.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,15 @@ function insertModalForm() {
}

function genUrlItem(title, content = '加载中...') {
const contentHTML = content.startsWith('http')
? `<a href="${content}" download>${content}</a>`
: content

return `<div>
<div style="white-space: nowrap;">[${title}]</div>
<div class="url" data-status='0' style="word-break:break-all; word-wrap:break-word;">
<a href="${content}" download>${content}</a>
</div>
${contentHTML}
</div>
</div>`
}

Expand Down Expand Up @@ -183,7 +187,7 @@ async function insertResult(list) {
.then((vurl) => {
const url = decodeURIComponent(vurl)
saveLocal(item.href, url)
$msg.text(url)
$msg.html(`<a href="${url}" download>${url}</a>`)
$msg.data('status', '1')
})
.catch((error) => {
Expand Down
11 changes: 6 additions & 5 deletions src/agefans/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,20 @@ function replacePlayer() {
}

function showCurrentLink(vurl) {
const decodeVurl = decodeURIComponent(vurl)

if ($('#current-link').length) {
return $('#current-link').text(vurl)
$('#current-link').text(decodeVurl)
$('#current-link').attr('href', decodeVurl)
return
}
$(`
<div class="baseblock">
<div class="blockcontent">
<div id="wangpan-div" class="baseblock2">
<div class="blocktitle">本集链接:</div>
<div class="blockcontent">
<a class="res_links" id="current-link" download href="${decodeURIComponent(
vurl
)}">${decodeURIComponent(vurl)}</a>
<br>
<a class="res_links" id="current-link" download href="${decodeVurl}">${decodeVurl}</a>
</div>
</div>
</div>
Expand Down

0 comments on commit 4c7e459

Please sign in to comment.