求帮忙改个js脚本,点击按钮让它运行就自动点击,不想手动点一下,谢谢大神们
varfa=$("body");varbtn=$("<li></li>");varjson={"background-color":"rgba(70,196,38,0.8...
var fa = $("body");
var btn = $("<li></li>");
var json = {
"background-color": "rgba(70, 196, 38, 0.8)",
"height": "32px",
"width": "284px",
"padding": "8px",
"border": "2px dashed rgb(0, 85, 68)",
"z-index": 999999,
"cursor": "pointer",
"top": "50px",
"left": "0px",
"position": "fixed"
};
btn.css(json);
btn.html("<span id='lfsenior'><center>开启自动播放</center></span>");
fa.append(btn);
btn.click(function () {
setInterval(function () {
//获取iframe
var video = $("iframe").contents().find("iframe").contents();
//播放函数
var play = function () {
video.find("#video > button").click();
var jy = video.find("#video > div.vjs-control-bar > div.vjs-volume-panel.vjs-control.vjs-volume-panel-vertical > button");
if (jy.attr("title") != "取消静音") {
jy.click()
}
}
//如果正在加载
var load = video.find("#loading");
if (load.css("visibility") != "hidden") {
return;
}
//获取当前进度
var spans = video.find("#video > div.vjs-control-bar > div.vjs-progress-control.vjs-control > div").attr("aria-valuenow");
// 如果还没播放完
if (spans != 100) {
play();
}
//如果播放结束
if (spans == 100) {
var bs = false;
$(".onetoone").find(".flush").each(function () {
if (bs) {
$(this).prev("a").on('click', "#coursetree>ncells", function () {
console.log("已结束章节:" + $(this).prev("a").attr("title"))
})
var str = $(this).prev("a").attr("href");
str = str.match(/'(\S*)'/)[1];
var reg = new RegExp("'", "g");
str = str.replace(reg, "");
var href = str.split(",");
getTeacherAjax(href[0], href[1], href[2])
bs = false;
}
if ($(this).css("display") == "block") {
bs = true;
}
})
}
$("#lfsenior").html("        自动模式已开启,本章进度:" + spans + "% ");
}, 100);
}); 展开
var btn = $("<li></li>");
var json = {
"background-color": "rgba(70, 196, 38, 0.8)",
"height": "32px",
"width": "284px",
"padding": "8px",
"border": "2px dashed rgb(0, 85, 68)",
"z-index": 999999,
"cursor": "pointer",
"top": "50px",
"left": "0px",
"position": "fixed"
};
btn.css(json);
btn.html("<span id='lfsenior'><center>开启自动播放</center></span>");
fa.append(btn);
btn.click(function () {
setInterval(function () {
//获取iframe
var video = $("iframe").contents().find("iframe").contents();
//播放函数
var play = function () {
video.find("#video > button").click();
var jy = video.find("#video > div.vjs-control-bar > div.vjs-volume-panel.vjs-control.vjs-volume-panel-vertical > button");
if (jy.attr("title") != "取消静音") {
jy.click()
}
}
//如果正在加载
var load = video.find("#loading");
if (load.css("visibility") != "hidden") {
return;
}
//获取当前进度
var spans = video.find("#video > div.vjs-control-bar > div.vjs-progress-control.vjs-control > div").attr("aria-valuenow");
// 如果还没播放完
if (spans != 100) {
play();
}
//如果播放结束
if (spans == 100) {
var bs = false;
$(".onetoone").find(".flush").each(function () {
if (bs) {
$(this).prev("a").on('click', "#coursetree>ncells", function () {
console.log("已结束章节:" + $(this).prev("a").attr("title"))
})
var str = $(this).prev("a").attr("href");
str = str.match(/'(\S*)'/)[1];
var reg = new RegExp("'", "g");
str = str.replace(reg, "");
var href = str.split(",");
getTeacherAjax(href[0], href[1], href[2])
bs = false;
}
if ($(this).css("display") == "block") {
bs = true;
}
})
}
$("#lfsenior").html("        自动模式已开启,本章进度:" + spans + "% ");
}, 100);
}); 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询