【智慧职教】挂课插件,支持看视频,看图文,看文档,主题讨论
// ==UserScript==
// @name 【智慧职教】挂课插件,支持看视频,看图文,看文档,主题讨论
// @namespace https://bbs.tampermonkey.net.cn/
// @description 用户智慧职教挂机
// @version 1.0.3
// @author 小了白了兔
// @storageName yike
// @compatible chrome firefox edge
// @grant unsafeWindow
// @grant GM_xmlhttpRequest
// @grant GM_xmlhttpRequest
// @grant GM_notification
// @grant GM_addStyle
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// @grant GM_openInTab
// @grant GM_addValueChangeListener
// @grant GM_removeValueChangeListener
// @match *://*
// @connect 85530a3e-fc46-4ea4-a542-160dad54a088.bspapp.com
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js
// @require https://cdn.bootcdn.net/ajax/libs/interact.js/1.10.17/interact.min.js
// @require-css https://vkceyugu.cdn.bspapp.com/VKCEYUGU-85530a3e-fc46-4ea4-a542-160dad54a088/5895b760-6bac-4f7f-9602-82b3465bbbae.css
// @require https://scriptcat.org/lib/738/1.0.5/yike_pub.js
// ==/UserScript==
//--------脚本部分开始
const jiaoben=[{script_name:"智慧职教-我的中心",script_id:"10005",element:".main .main-wrapper .mode-wrapper .mode-body .tabs-body #openingData",load_option:true,run:function(){alert("1.请开启弹窗权限,否则脚本无法运行。若已开启请忽略");fee.start_fee();window.setInterval(function(){console.log(get_format_date()+" 向study页发送active消息");page_b.postMessage({event:"keep_active",source:b},"*")},100000);let page_b;const b="main";const a=$("#openingData a:contains(课程学习)").toArray();window.addEventListener("message",function(g){const f=g.data;const d=f.source;const c=f.event;if(d!="study"){return}if(c=="class_start"){page_b=g.source}if(c=="class_complete"){$(document).trigger("class_complete")}if(c=="add_log"){yike_log(f.type,f.content)}},false);$(document).on("class_ready",function(d){if(a.length==0){yike_log("normal","您已完成所有课程学习");stop();return}a[0].click();const c=$(a[0]).parent().parent().parent().find(".course-name").text();yike_log("normal","开始学习---《"+c+"》")});$(document).on("class_complete",function(c){a.shift();page_b.close();if(a.length==0){yike_log("normal","您已完成所有课程学习");stop();return}$(document).trigger("class_ready")});$(document).trigger("class_ready")},stop:function(){yike_log("error","挂机结束,脚本停止运行");$(document).off()}},{script_name:"智慧职教-学习页面",script_id:"10005",element:".body-withmenu .learn-header .header-wrap .pull-right .info #learnTimer",run:function(){const b="study";unsafeWindow.confirm=function(){console.log(get_format_date()+"我被HOOK了");return true};unsafeWindow.alert=function(){return true};window.confirm=function(){console.log(get_format_date()+"我被HOOK了");return true};window.alert=function(){return true};window.top.opener.postMessage({event:"class_start",source:b},"*");const a=window.setInterval(function(){if(lost_time>=5){stop();window.clearInterval(a);alert("挂机过程中,不要关闭主页面。脚本运行停止")}else{console.log("失去连接第 "+lost_time+"次");lost_time=lost_time+1}},110000);window.addEventListener("message",function(g){const f=g.data;const d=f.source;if(d!="main"){return}const c=f.event;if(c=="keep_active"){console.log(get_format_date()+"----学习页收到通知");lost_time=0}},false);window.setTimeout(function(){const c=get_tag("#learnMenu .s_sectionlist .s_point[completestate=0]").toArray();$(document).on("mission_ready",function(d){if(mission[0].type=="video"){$(mission[0].ele).on("ended",function(){console.log("播放结束");$(document).trigger("mission_complete")});return}});$(document).on("mission_complete",function(d){mission.shift();if(mission.length==0){$(document).trigger("course_complete");return}$(document).trigger("mission_ready")});$(document).on("course_complete",function(d){window.opener.postMessage({event:"add_log",type:"normal",content:"完成学习----《"+$(c[0]).find(".s_pointti").text()+"》",source:b},"*");c.shift();if(c.length==0){window.top.opener.postMessage({event:"class_complete",source:b},"*");return}$(document).trigger("course_ready")});$(document).on("course_ready",function(d){window.opener.postMessage({event:"add_log",type:"normal",content:"开始学习----《"+$(c[0]).find(".s_pointti").text()+"》",source:b},"*");c[0].click();window.setTimeout(function(){const j=$(c[0]).attr("itemtype");if(j=="video"){const h=get_tag("video");h.get(0).muted="muted";h.get(0).play();const i=window.setInterval(function(){if(h.get(0).ended){console.log("视频播放结束");$(document).trigger("course_complete");window.clearInterval(i)}},10000)}else{if(j=="doc"){window.setTimeout(function(){console.log("完成看文档");$(document).trigger("course_complete")},10000)}else{if(j=="topic"){const e="感谢老师分享";const g=get_tag("#myEditor").get(0).ownerDocument.defaultView.myEditor;const f=get_tag("#commentDiv .submit a");g.setContent(e);window.setTimeout(function(){f.get(0).click()},5000);window.setTimeout(function(){$(document).trigger("course_complete")},10000)}else{if(j=="text"){window.setTimeout(function(){console.log("完成看图文");$(document).trigger("course_complete")},10000)}else{if(j=="exam"){window.setTimeout(function(){window.top.opener.postMessage({event:"add_log",type:"error",content:"考试任务,功能暂不支持,跳过该任务",source:b},"*");$(document).trigger("course_complete")},5000)}else{window.top.opener.postMessage({event:"add_log",type:"error",content:"未知任务,跳过。。。",source:b},"*");$(document).trigger("course_complete")}}}}}},5000)});$(document).trigger("course_ready")},4000)},stop:function(){$(document).off()}}];
$(window).on("load", function () {
window.setTimeout(function () {
const _script = get_script();
console.log(_script);
if (_script == undefined) {
console.log("对不起,未找到对应脚本\n 1.本提示由第三方脚本产生,如非本意,请在脚本控制台关闭脚本。 \n 2.如果您打开的页面为相应网课平台,说明脚本匹配失败,请联系作者。");
return;
}
run = _script.run;
stop = _script.stop;
if (_script.load_option) {
load_option();
} else {
run();
}
}, 2500);
});