Greasy Fork

Greasy Fork is available in English.

国家智慧教育公共服务平台|国家中小学智慧教育平台|教师研修|自动挂机刷课|自动答题

进入研修专题,然后选择到你要看课的网址,直接点进去就行,会自动开始刷课和挂机。

当前为 2023-07-21 提交的版本,查看 最新版本

// ==UserScript==
// @name         国家智慧教育公共服务平台|国家中小学智慧教育平台|教师研修|自动挂机刷课|自动答题
// @namespace    挂机刷课
// @version      3.0
// @license      CC BY-NC-SA
// @description  进入研修专题,然后选择到你要看课的网址,直接点进去就行,会自动开始刷课和挂机。
// @author       aluyunjie【bug+v:aluyunjiesmile】
// @match        https://basic.smartedu.cn/teacherTraining/courseDetail*
// @match        https://basic.smartedu.cn/training/*
// @match        https://basic.smartedu.cn/teacherTraining/courseIndex*
// @icon         https://www.zxx.edu.cn/favicon.ico
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==

(function() {
	'use strict';
	createLogBox();

	// 获取当前网址
	var currentURL = window.location.href;

	if (currentURL.includes("https://basic.smartedu.cn/training/2023sqpx")) {
		//判断用户是否登录
		//少个功能

		addTextToLogBox("脚本加载成功!");
		addTextToLogBox("有bug请反馈:微信:aluyunjiesmile");
		addTextToLogBox('脚本更新于2023-7-21');
		addTextToLogBox('开始执行,请等待15秒');
		setInterval(ChosePageTimer, 15000);
	}

	if (currentURL.includes("https://basic.smartedu.cn/teacherTraining/courseIndex?courseId")) {
		addTextToLogBox("请等待!")
		setTimeout(function() {
			document.querySelector(
				"#root > div > div > div > div > div > div > section > div > div.CourseIndex-module_course_1_SiV > div.CourseIndex-module_course-action_2eWDh > a"
				).click();
		}, 4000)
		setTimeout(function() {
			window.location.reload();
		}, 6000)

	}

	if (currentURL.includes('https://basic.smartedu.cn/teacherTraining/courseDetail?courseId')) {
		addTextToLogBox("已经进入视频播放界面!");
		setInterval(PlayingPageTimer, 5000);
	}




	// Your code here...
})();

function ChosePageTimer() {
	
	choseClassPage_ChoseClass();
	setTimeout(function(){
		window.location.reload();
	},3000)
	
}

function PlayingPageTimer() {

	jugeCurrentClassIsStudyDone();
	jugeVideoIsPlaying();
	jugePlayingPageNotPlay();

}

function jugePlayingPageNotPlay() {
	addTextToLogBox("检测首页学时是否足够!")
	var title = document.getElementsByClassName('fish-breadcrumb-link')[3].textContent;
	var jindu = GM_getValue(title);
	addTextToLogBox("外部首页显示进度:"+jindu);
	if(jindu === "完成"){
		window.close();
	}
	

}

function jugeVideoIsPlaying() {
	var trueOrFasle = document.querySelector("video").paused;
	if (trueOrFasle) {
		addTextToLogBox("视频未在播放");

		//检测是否有题,
		if (shiFouYouTi()) {
			//有题--业务逻辑
			doQuestionAnwser();
		} else {
			//无题--业务逻辑
			PlayVideoButton();
		}

	} else {
		addTextToLogBox("视频正在播放,设置倍速3倍");
		document.querySelector("video").playbackRate = 3;
	}
}


function choseClassPage_ChoseClass() {

	for (var i = 1; i < 8; i++) {
		var studyTitle;
		var studyedTime;
		var studyTime;
		//课程题目
		studyTitle = document.querySelector(
			"#root > div > div > div > div > div.fish-spin-nested-loading.x-edu-nested-loading > div > div:nth-child(1) > div:nth-child(" +
			i +
			") > div > div > div.index-module_content_7FjRb > div.index-module_detail_1JEVZ > div.index-module_title_8i8E6"
			).textContent;

		//已学
		var studyedTimeOBJ = document.querySelector(
			"#root > div > div > div > div > div.fish-spin-nested-loading.x-edu-nested-loading > div > div:nth-child(1) > div:nth-child(" +
			i +
			") > div > div > div.index-module_process_3RHjg > div:nth-child(3) > span.index-module_processCMy_2HvHz"
			);
		if (studyedTimeOBJ === null) {
			studyedTime = '0'
		} else {
			studyedTime = document.querySelector(
				"#root > div > div > div > div > div.fish-spin-nested-loading.x-edu-nested-loading > div > div:nth-child(1) > div:nth-child(" +
				i +
				") > div > div > div.index-module_process_3RHjg > div:nth-child(3) > span.index-module_processCMy_2HvHz"
				).textContent;
		}
		//应学
		var studyTimeOBJ = document.querySelector(
			"#root > div > div > div > div > div.fish-spin-nested-loading.x-edu-nested-loading > div > div:nth-child(1) > div:nth-child(" +
			i + ") > div > div > div.index-module_process_3RHjg > div:nth-child(3) > span:nth-child(2)");
		if (studyTimeOBJ === null) {
			studyTime = '0';
		} else {
			studyTime = document.querySelector(
					"#root > div > div > div > div > div.fish-spin-nested-loading.x-edu-nested-loading > div > div:nth-child(1) > div:nth-child(" +
					i + ") > div > div > div.index-module_process_3RHjg > div:nth-child(3) > span:nth-child(2)")
				.textContent;
		}

		var num1 = parseFloat(studyedTime);
		var num2 = parseFloat(studyTime);
		addTextToLogBox("题目:" + studyTitle + ",已学:" + studyedTime + "应学:" + studyTime);
		if (num1 >= num2) {
			addTextToLogBox("执行设置值")
			GM_setValue(studyTitle, "完成");
		}

		var isChoseed = GM_getValue(studyTitle);
		console.log(isChoseed)
		if (isChoseed === "进行") {
			addTextToLogBox(studyTitle + "已经选过,等待刷课")
			break;
		}

		if (num1 < num2) {
			addTextToLogBox(studyTitle + "未完成,开始选择")
			document.querySelector(
				"#root > div > div > div > div > div.fish-spin-nested-loading.x-edu-nested-loading > div > div:nth-child(1) > div:nth-child(" +
				i +
				") > div > div > div.index-module_content_7FjRb > div.index-module_detail_1JEVZ > div.index-module_title_8i8E6"
				).click();
			GM_setValue(studyTitle, "进行");
			break;
		}
		
	}
	if(i>= 8){
		document.querySelector("#rc-tabs-0-panel-c227b3de-65e4-4cb8-957c-d8ab4bbc0cc6 > div:nth-child(2) > div > div > div.index-module_content_7FjRb > div.index-module_detail_1JEVZ > div.index-module_title_8i8E6").click();
		window.close();
	}
	
}




function jugeCurrentClassIsStudyDone() {
	var titleText = document.getElementsByClassName('resource-item resource-item-train resource-item-active')[0].getElementsByTagName('i')[1].title

	if (titleText == '未开始') {
		addTextToLogBox("当前视频暂未看完");
	}


	if (titleText == '进行中') {
		addTextToLogBox("当前视频暂未看完。");
		addTextToLogBox("请保持在本页,要不会暂停播放视频");
	}

	if (titleText == '已学完') {
		addTextToLogBox("当前视频已经看完,选择下一个");

		findNextVideoPlay();

	}

}



//找到下一个播放的视频
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
	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 addTextToLogBox(TextLog) {

	// 获取目标 <div> 元素
	var targetDiv = document.getElementById('logBox'); // 替换为你的目标 <div> 元素的 ID
	targetDiv.appendChild(document.createElement('br'));
	// 创建文本节点
	var textNode = document.createTextNode(TextLog);
	// 添加文本节点到目标 <div> 元素
	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);

}