元素的 ID
targetDiv.appendChild(document.createElement('br'));
// 创建文本节点
var textNode = document.createTextNode(TextLog);
// 添加文本节点到目标
元素
targetDiv.appendChild(textNode);
targetDiv.scrollTop = targetDiv.scrollHeight;
}
//创建日志框
function createLogBox() {
var logBox = document.createElement('div');
logBox.id = 'logBox';
logBox.style.position = 'fixed';
logBox.style.bottom = '0';
logBox.style.left = '0';
logBox.style.width = '200px';
logBox.style.height = '200px';
logBox.style.backgroundColor = 'black'; // 更改背景颜色为黑色
logBox.style.color = 'green'; // 更改文本颜色为绿色
logBox.style.overflow = 'auto';
logBox.style.padding = '10px';
logBox.style.fontFamily = 'Arial, sans-serif';
logBox.style.whiteSpace='pre-wrap';
document.body.appendChild(logBox);
}
function zhouqizhixing(){
//检测题目以及做单选题
var shiFouYouTi = document.querySelector("#modal > div > div > div.question-header > div > h4")
if(shiFouYouTi == null){
console.log("题目检测中。。。检测无题!")
addTextToLogBox('题目检测中。。。检测无题!');
}else{
var text = shiFouYouTi.textContent
if(text == '课堂练习'){
console.log("检测有题,正在做题")
addTextToLogBox('检测有题,正在做题');
var danXuanDuoXuan = document.querySelector("#modal > div > div > div.question-body > div.question-title > span").textContent
//题型
if(danXuanDuoXuan == '【单选题】'){
document.querySelector("#modal > div > div > div.question-body > ul > li:nth-child(1)").click()
//答完题实现点击
setTimeout(clickQueDingAnNiu(),1000)
setTimeout(clickQueDingAnNiu(),1000)
}
if(danXuanDuoXuan == '【是非题】'){
document.querySelector("#modal > div > div > div.question-body > ul > li:nth-child(1)").click()
//答完题实现点击
setTimeout(clickQueDingAnNiu(),1000)
setTimeout(clickQueDingAnNiu(),1000)
}
if(danXuanDuoXuan == '【多选题】'){
document.querySelector("#modal > div > div > div.question-body > ul > li:nth-child(1)").click()
document.querySelector("#modal > div > div > div.question-body > ul > li:nth-child(2)").click()
//答完题实现点击
setTimeout(clickQueDingAnNiu(),1000)
setTimeout(clickQueDingAnNiu(),1000)
}
}
}
//点击确定按钮
for(var i = 0 ; i<=50 ; i++){
var querySelectors = "#layui-layer" + i + " div.layui-layer-btn > a"
var dianjiqueding = document.querySelector(querySelectors)
if(dianjiqueding == null){
console.log("没找到确定按钮的button")
addTextToLogBox('没找到确定按钮的button,继续播放');
}else{
//点击确定按钮
dianjiqueding.click()
setTimeout(playVideodianjianniu(),1500)
}
}
}
function clickQueDingAnNiu(){
document.querySelector("#submit").click()
}
function playVideodianjianniu(){
//播放器点击播放按钮
document.querySelector("#video-Player > xg-start > div.xgplayer-icon-play").click()
}
(function() {
'use strict';
createLogBox();
// 获取当前网址
var currentURL = window.location.href;
// 判断当前网址是否包含指定字符串
if (currentURL.includes('https://teacher.vocational.smartedu.cn/h/subject/teaching/')) {
addTextToLogBox("脚本加载成功!");
addTextToLogBox("有bug请反馈:微信:aluyunjiesmile");
addTextToLogBox('脚本更新于2023-7-16');
addTextToLogBox("请点击所需要播放的课程")
}
if (currentURL.includes('https://core.teacher.vocational.smartedu.cn/p/course/vocational/i')) {
console.log('当前网址包含指定字符串');
addTextToLogBox("请点击开始学习按钮")
}
if(currentURL.includes('https://core.teacher.vocational.smartedu.cn/p/course/vocational/v')){
setInterval(zhouqizhixing,5000,"每隔5秒执行一次");
}
})();