// ==UserScript== // @name 我就是积极分子 // @namespace laoxin.top // @version 2.2.4 // @description 西南石油大学入党积极分子网课自动播放 // @author 老新 // @match http://rdjy.swpu.edu.cn/jjfz/lesson/* // @grant unsafeWindow // @grant GM_getValue // @grant GM_setValue // @grant GM_xmlhttpRequest // @require https://cdn.bootcdn.net/ajax/libs/jquery/2.0.0/jquery.js // @downloadURL none // ==/UserScript== let settings = { // 1表示开启,0表示关闭 // 视频播放相关 video: 1, // 视频弹窗自动关闭,默认开启 jump: 1, // 自动切换下一个视频任务点,默认开启(需要开启视频弹窗自动关闭) back: 1, // 視頻播放完成自動回到章節列表,默认关闭(需要开启自动切换到下一个任务点) class: 1, // 自动切换到未播放的章节,默认关闭(需要开启視頻播放完成自動回到章節列表) // 章节测试相关 copy: 1, // 允许右键复制,开启右键菜单 answer: 1 // 显示“查答案”按钮(网络题库不保证准确性) }, _self = unsafeWindow, url = location.pathname, classLists = [], videoLists = []; let $$ = top.jQuery; if (url == "/jjfz/lesson/video" && settings.class) { if (GM_getValue("dont_note")) { let passNum = 0; let cl = setInterval(() => { getClassList(); passNum = $$(".lesson_pass").length; if (classLists.length) { jumpToVideoFromClass(passNum) } if (classLists.length) clearInterval(cl); }, 1000); } else { video_note(); } } if (url == "/jjfz/lesson/play" && settings.video) { playVideo(); let nextVideoFlag = false, nextClassFlag = false; let vp = setInterval(() => { if (!videoLists.length) { getVideoList(); } nextVideoFlag = closeAlert(); if (settings.jump) { nextClassFlag = jumpToVideo(videoLists); if (nextVideoFlag) nextClassFlag = nextVideo(videoLists); } if (settings.back) { if (nextClassFlag) goBack(); } }, 1000) } if (url == "/jjfz/lesson/exam" && settings.copy) { openCopy(); test_note(); let ga = setInterval(() => { if ($$("#get_answer").length == 0) { $$("#next_question").after("查答案"); $$("#next_question").after(" "); $$("#get_answer").click(function () { getAnswer(); }) } }, 1000) } function getClassList() { let classList = [] if ($$(".l_list_right")) { $$(".l_list_right").each((ind, ele) => { if ($$(ele).find("div .r_read").text() == " 必 修 ") { classList.push($$(ele).find("h2 a")) } }) } classLists = classList; } function getVideoList() { if ($$(".video_lists li").length) { console.log("当前视频" + $$(".video_red1").text()) videoLists = $$(".video_lists li"); } } function jumpToVideoFromClass(passNum) { if (passNum != classLists.length) { $$(classLists[passNum]).attr('id', 'aRemoveAllTxt'); document.getElementById("aRemoveAllTxt").click(); } } function closeAlert() { if ($$(".public_submit").length) { //console.log("视频数量" + $$(".video_lists li")) let text = $$(".public_text").text(); if (text.indexOf("当前视频播放完毕") >= 0) { return true; } else if (text.indexOf("该课程视频你上次观看到") >= 0) { $$(".public_cancel").attr('id', 'aRemoveAllTxt'); document.getElementById("aRemoveAllTxt").click(); return false; } else { $$(".public_submit").attr('id', 'aRemoveAllTxt'); document.getElementById("aRemoveAllTxt").click(); return false; } } } function nextVideo(videoList) { let index = $$(videoList).index($$(".video_red1")); if (videoList[index + 1]) { $$(videoList[index + 1]).children("a").attr('id', 'aRemoveAllTxt'); document.getElementById("aRemoveAllTxt").click(); return false; } else { return true; } } function jumpToVideo(videoList) { if ($$(".video_red1").find("a").attr("style") == "width:70%;color:red") { let index = $$(videoList).index($$(".video_red1")); if (videoList[index + 1]) { $$(videoList[index + 1]).children("a").attr('id', 'aRemoveAllTxt'); document.getElementById("aRemoveAllTxt").click(); } else { return true; } } } function goBack() { $$(".video_goback").attr('id', 'aRemoveAllTxt'); document.getElementById("aRemoveAllTxt").click(); } function playVideo() { _self.studyTime = function () { var diff_time = 5000; $.ajax({ type: "POST", cache: false, dataType: "json", url: "/jjfz/lesson/study_time", data: { rid: "630089", study_time: diff_time, _xsrf: $(":input[name='_xsrf']").val() }, success: function () { } }); flag = setTimeout("studyTime()", diff_time); } _self.players[0].on('pause', function (event) { if ($$(".public_submit").length) { } else _self.players[0].play(); }); } function getAnswer() { let question = $$(".exam_h2").text(); console.log(question) GM_xmlhttpRequest({ method: 'POST', url: 'http://cx.lyck6.cn/api/', headers: { 'Content-type': 'application/x-www-form-urlencoded' }, data: 'question=' + question, timeout: 5000, onload: function (xhr) { if (!1) { } else if (xhr.status == 200) { let obj = $$.parseJSON(xhr.responseText) //return obj.answer; let answer = obj.answer; if (obj.answer.indexOf("token") != -1) answer = "网络题库目前没有答案哦,推荐使用学小易或百度查询!(搜不出来可以多点几次,后台会在百度搜索答案)"; if ($$(".e_cont_title").find("span").text() == "判断题") { if (answer != "网络题库目前没有答案哦,推荐使用学小易或百度查询!(搜不出来可以多点几次,后台会在百度搜索答案)") { if (question.indexOf(answer) != -1) { answer = "对!" } else { answer = "错!" } } } if ($$(".fuck_answer").length == 0) { $$(".answer_list").after("
由于精力有限,实在无法提供用户界面
' + '详细设置请修改源代码
' + '欢迎捐赠,对于你的捐赠表示由衷感谢 |点击向我捐赠|
' + '本脚本免费使用严谨倒卖
' + '如果你是以收费方式获得此脚本
' + '请立即退款并在官方页面下载原版 |点我下载原版|
', 'public_cont1', function () { $(".public_close").click(); //此为关闭方法 GM_setValue("dont_note", false) }, function () { $(".public_close").click(); //此为关闭方法 GM_setValue("dont_note", false) location.href = "https://greasyfork.org/zh-CN/scripts/414487-%E6%88%91%E5%B0%B1%E6%98%AF%E7%A7%AF%E6%9E%81%E5%88%86%E5%AD%90"; }); } function test_note() { alert_note(1, ["关闭"], "我就是积极分子答题使用说明", '由于精力有限,实在无法提供用户界面
' + '题库来源于网络,不保证准确性!!!
' + '题库来源于网络,搜不出来正常(哈哈)
' + '作者没钱搞服务器整题库,所以你懂的
' + '将就用一下就好,建议打开复制自行搜索!
' + '推荐使用学小易,非常准确,或者百度
' + '欢迎捐赠,对于你的捐赠表示由衷感谢 |点击向我捐赠|
', 'public_cont1', function () { $(".public_close").click(); //此为关闭方法 }); } function alert_note(btn_num, btn_text, note_text, public_text, public_cont_class, submit_fun, cancel_fun) { if (btn_num == 1) { var public_a = '' + btn_text[0] + ''; } else { var public_a = '' + btn_text[0] + ' ' + btn_text[1] + ''; } var public_html = '