// ==UserScript== // @name 国家智慧教育公共服务平台|国家中小学智慧教育平台|教师研修|自动挂机刷课|自动答题 // @namespace 挂机刷课 // @version 2024.02.05.2203 // @license CC BY-NC-SA // @description 【bug+v:aluyunjiesmile】适配中教学教师寒假研修:https://basic.smartedu.cn/training/2024hjpx // @author aluyunjie // @match https://basic.smartedu.cn/teacherTraining/courseDetail* // @match https://basic.smartedu.cn/training/* // @match https://basic.smartedu.cn/training/2024hjpx // @match https://basic.smartedu.cn/teacherTraining/courseIndex* // @icon https://www.zxx.edu.cn/favicon.ico // @grant GM_setValue // @grant GM_getValue // @downloadURL none // ==/UserScript== var PrimaryAndSecondarySchoolsLinks =[ //弘扬教育家精神 勇担强国建设使命 "https://basic.smartedu.cn/teacherTraining/courseDetail?courseId=08e005b6-442f-40d0-bf5d-ac3ed35feaeb&tag=2024%E5%B9%B4%E5%AF%92%E5%81%87%E6%95%99%E5%B8%88%E7%A0%94%E4%BF%AE&channelId=&libraryId=bb042e69-9a11-49a1-af22-0c3fab2e92b9&breadcrumb=2024%E5%B9%B4%E5%AF%92%E5%81%87%E6%95%99%E5%B8%88%E7%A0%94%E4%BF%AE", //关爱教师 提升从教幸福感 "https://basic.smartedu.cn/teacherTraining/courseDetail?courseId=1a11eeee-8d43-4d3b-8818-1b842a0ee966&tag=2024%E5%B9%B4%E5%AF%92%E5%81%87%E6%95%99%E5%B8%88%E7%A0%94%E4%BF%AE&channelId=&libraryId=bb042e69-9a11-49a1-af22-0c3fab2e92b9&breadcrumb=2024%E5%B9%B4%E5%AF%92%E5%81%87%E6%95%99%E5%B8%88%E7%A0%94%E4%BF%AE", //造良匠之师 育大国工匠 "https://basic.smartedu.cn/teacherTraining/courseDetail?courseId=47678428-4c27-4526-a8cf-15fb65138617&tag=2024%E5%B9%B4%E5%AF%92%E5%81%87%E6%95%99%E5%B8%88%E7%A0%94%E4%BF%AE&channelId=&libraryId=bb042e69-9a11-49a1-af22-0c3fab2e92b9&breadcrumb=2024%E5%B9%B4%E5%AF%92%E5%81%87%E6%95%99%E5%B8%88%E7%A0%94%E4%BF%AE" ]; //寒假学时配置 var hjstudyTimes =[12,7,25]; (function() { 'use strict'; createLogBox(); // 获取当前网址 var currentURL = window.location.href; if (currentURL.includes("https://basic.smartedu.cn/training/2024hjpx")) { addTextToLogBox("脚本加载成功!"); addTextToLogBox("有bug请反馈:微信:aluyunjiesmile"); addTextToLogBox('脚本更新于2024-02-05'); setTimeout(function(){ //全局数组下标 let index = 0; GM_setValue("下标", index); GM_setValue("类别","中小学"); openNewWindow(PrimaryAndSecondarySchoolsLinks[index]); },5000) } if (currentURL.includes('https://basic.smartedu.cn/teacherTraining/courseDetail?courseId')) { addTextToLogBox("脚本加载成功已经进入视频播放界面!"); setInterval(PlayingPageTimer, 5000); } // Your code here... })(); function PlayingPageTimer() { jugeCurrentClassIsStudyDone(); jugeVideoIsPlaying(); jugePlayingPageIsNotPlay(); } function jugePlayingPageIsNotPlay() { //换课逻辑 var percentHound = 0; var GMindex = GM_getValue("下标"); //setp01 判断视频播放页面有多少已经到达100%的 percentHound = document.getElementsByClassName('iconfont icon_checkbox_fill').length; //step02 从油猴脚本中取出对应下标的对应学时 var studyedtimes = hjstudyTimes[GMindex]; //stp03进行判断 if(parseInt(percentHound)>= parseInt(studyedtimes)){ var GMindex2 = GM_getValue("下标"); let index = ++GMindex2; addTextToLogBox(index); GM_setValue("下标", index); window.location.href = PrimaryAndSecondarySchoolsLinks[index]; }else{ addTextToLogBox("当前任务暂未完成课时,等待继续完成") } } function jugeVideoIsPlaying() { var trueOrFasle = document.querySelector("video").paused; if (trueOrFasle) { addTextToLogBox("视频未在播放"); //检测是否有题, if (shiFouYouTi()) { //有题--业务逻辑 doQuestionAnwser(); } else { //无题--业务逻辑 PlayVideoButton(); } } else { addTextToLogBox("视频正在播放,设置倍速2倍"); //用户可以来看这个,最高2倍速播放,因为有限制,如果不信,你可以把下面的数字3改为1-16中的任何数字,代表的是1-16倍 document.querySelector("video").playbackRate = 2; } } function jugeCurrentClassIsStudyDone() { var titleText = document.getElementsByClassName('resource-item resource-item-train resource-item-active')[0].getElementsByTagName('i')[0].title if (titleText == '未开始') { addTextToLogBox("当前视频暂未看完"); } if (titleText == '进行中') { addTextToLogBox("当前视频暂未看完。"); addTextToLogBox("请保持在本页,要不会暂停播放视频"); } if (titleText == '已学完') { addTextToLogBox("当前视频已经看完,选择下一个"); findNextVideoPlay(); setTimeout(function() { window.location.reload(); }, 2000) } } //找到下一个播放的视频 function findNextVideoPlay() { //stp01,先进行遍历点击,让iconfont icon_checkbox_linear 可以显示出来 for (var i = 0; i < 10; i++) { var clickButton = document.getElementsByClassName('fish-collapse-header')[i]; if (clickButton === undefined) { break; } else { clickButton.click(); } } //stp02,先找进行中的视频观看,如果没有进行中的视频,则找未观看的视频 for (var j = 0; i < 10; i++) { var nextVideo = document.getElementsByClassName('iconfont icon_processing_fill')[j]; if (nextVideo === undefined) { continue; } else { nextVideo.click() } } //set03,找不到视频就点击未观看的视频进行点击观看 document.getElementsByClassName('iconfont icon_checkbox_linear')[0].click(); setTimeout(PlayVideoButton,2000) } function danjixiayitianniu() { //单击下一题按钮 document.querySelector( "#root > div > div > div > div > div > div > div.index-module_detail-main_bdFS3 > div.index-module_detail-main-l_1b8KB > div.index-module_video-wrapper_22Dc0 > div > div.index-module_markerExercise_KM5bU > div > div.index-module_footer_3r1Yy > button" ).click() } function doQuestionAnwser() { addTextToLogBox("做题"); var tixing = document.getElementsByClassName('_qti-title-prefix-qtype')[0].textContent; if (tixing == '单选题') { addTextToLogBox("题型为单选题") console.log("题型为单选题") console.log("开始做题") //选择第一项 document.getElementsByClassName("nqti-check")[0].click() setTimeout(danjixiayitianniu(), 1000) setTimeout(danjixiayitianniu(), 1000) } if (tixing == '多选题') { addTextToLogBox("题型为多选") console.log("题型为多选") console.log("开始做题") //选择第一项 document.getElementsByClassName("nqti-check")[0].click() //选择第二项 document.getElementsByClassName("nqti-check")[1].click() document.querySelector( "#root > div > div > div > div > div > div > div.index-module_detail-main_bdFS3 > div.index-module_detail-main-l_1b8KB > div.index-module_video-wrapper_22Dc0 > div > div.index-module_markerExercise_KM5bU > div > div.index-module_footer_3r1Yy > button" ).click() setTimeout(danjixiayitianniu(), 1000) setTimeout(danjixiayitianniu(), 1000) } if (tixing == '判断题') { addTextToLogBox("题型为判断") console.log("题型为判断") console.log("开始做题") //选择第一项 document.getElementsByClassName("nqti-check")[0].click() document.querySelector( "#root > div > div > div > div > div > div > div.index-module_detail-main_bdFS3 > div.index-module_detail-main-l_1b8KB > div.index-module_video-wrapper_22Dc0 > div > div.index-module_markerExercise_KM5bU > div > div.index-module_footer_3r1Yy > button" ).click() setTimeout(danjixiayitianniu(), 1000) setTimeout(danjixiayitianniu(), 1000) } } //检测是否有题,如果有题则返回true ,否则返回false function shiFouYouTi() { var question = document.getElementsByClassName('question_player-container question_player')[0]; if (question === undefined) { addTextToLogBox("检测无题") return false; } else { addTextToLogBox("检测有题"); return true; } } function PlayVideoButton() { //切换新的视频进行点击我知道了/为空则为undefined var button = document.getElementsByClassName('fish-modal-body')[0]; if(button === undefined){ }else{ button.getElementsByTagName('button')[0].click(); } var video = document.querySelector("video"); video.play(); video.autoplay = true; //有些时候,点击按钮没反应。获取到本网页的焦点 for (var i = 0; i < 10; i++) { var clickButton = document.getElementsByClassName('fish-collapse-header')[i]; if (clickButton === undefined) { break; } else { clickButton.click(); } } //点击播放按钮,为空则为undefined addTextToLogBox("点击按钮,如果长时间没反应,请点击一下当前页面"); document.getElementsByClassName('vjs-big-play-button')[0].click(); var iknow = document.querySelector( "#main-content > div.content > div.index-module_container_4pMtL > div > div > micro-app > micro-app-body > div:nth-child(7) > div > div.fish-modal-wrap > div > div.fish-modal-content > div > div > div.fish-modal-confirm-btns > button" ); if (iknow === null) { } else { iknow.click(); } } function openNewWindow(url) { window.open(url, "_blank"); } //日志函数 function addTextToLogBox(TextLog) { // 获取目标