按钮重复点击
This commit is contained in:
parent
06e16f67e5
commit
79d3f38552
@ -2,7 +2,7 @@
|
||||
// @name 央视网视频下载
|
||||
// @description Download videos from cctv.com with one click
|
||||
// @namespace https://iteay.top/
|
||||
// @version 1.2
|
||||
// @version 1.2.1
|
||||
// @author BlackTeay
|
||||
// @match https://*.cctv.com/*
|
||||
// @updateURL https://git.jlntv.work/blackteay/tampermonkey-script/raw/branch/master/libiary/Download_CCTV_Video.js
|
||||
@ -28,6 +28,7 @@
|
||||
*/
|
||||
function appendDownloadEle(videoJQ, title, videoSrc) {
|
||||
let downloadIdAttrName = videoJQ.attr("id") + "_download";
|
||||
var downloading=false
|
||||
console.log(downloadIdAttrName)
|
||||
if ($("#" + downloadIdAttrName).length <= 0) {
|
||||
// 【下载】按钮
|
||||
@ -41,7 +42,7 @@
|
||||
"padding": "5px 10px",
|
||||
"display": "inline-block",
|
||||
"margin-top": "1em",
|
||||
// "margin-left": "0.5rem"
|
||||
//"margin-left": "0.5em"
|
||||
});
|
||||
downloadJQ.attr("id", downloadIdAttrName);
|
||||
downloadJQ.attr("href", videoSrc);
|
||||
@ -53,6 +54,13 @@
|
||||
// 为下载按钮绑定单击事件下载视频
|
||||
downloadJQ.on("click", function (event) {
|
||||
// console.log("下载视频:" + $(this).attr("id") + ", href=" + $(this).attr("href"));
|
||||
|
||||
if(downloading==true){
|
||||
console.log("视频下载中,请勿再次点击")
|
||||
return false;
|
||||
}else{
|
||||
downloading=true
|
||||
}
|
||||
// 阻止 a 标签默认行为
|
||||
event.preventDefault();
|
||||
if ($(this).attr("href")) {
|
||||
@ -73,8 +81,9 @@
|
||||
document.body.appendChild(downloadLink);
|
||||
downloadLink.click();
|
||||
downloadLink.remove();
|
||||
downloading=false;
|
||||
}else if(this.status == 404){
|
||||
console.log("网页不存在");
|
||||
console.log("视频不存在");
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user