Greasy Fork is available in English.

公共卫生与预防医学继续教育平台“大学习”-自动-vx:shuake345

自动跳视频|自动考试|请配合软件,否则无效|秒所有考试-vx:shuake345

// ==UserScript==
// @name         公共卫生与预防医学继续教育平台“大学习”-自动-vx:shuake345
// @version      0.2
// @description  自动跳视频|自动考试|请配合软件,否则无效|秒所有考试-vx:shuake345
// @author       vx:shuake345
// @match        *://*.cmechina.net/cme/*
// @match        *://*.haoyisheng.com/qypx/hb/*
// @match        *://*.cpma.org.cn/*
// @icon         https://service.cpma.org.cn/edu/assets/logo-4ee47815.png
// @namespace https://greasyfork.org/users/1072479
// ==/UserScript==

(function() {
	'use strict';
    window.alert = function() {}
	window.onbeforeunload = null
	window.confirm = function() {
		return true
	}
    document.addEventListener("visibilitychange", function() {
		console.log(document.visibilityState);
		if (document.visibilityState == "hidden") {
        //yincang
        } else if (document.visibilityState == "visible") {
			if (document.URL.search("cme/myFavorite") > 1) {
				setTimeout(sx, 1000)
			}
		}
	});
    function gbclose() {
		window.close()
	}
    function sx() {
        window.location.reload()
    }

    function ERROR(){
    if(document.querySelector('h1').innerText=='502 Bad Gateway'){
        setTimeout(sx,1211)
    }
    }
    setTimeout(ERROR,5241)
    function Ggerenzhongxin(){
        if (document.URL.search("cme/myFavorite") > 1) {
            var KECheng=document.querySelectorAll("body > div > div > div.j_right > div > div > div > table > tbody > tr > td:nth-child(3)")//[1].innerText
				for (var i = 0; i < KECheng.length; i++) {
			if (KECheng[i].innerText == '学习中'||KECheng[i].innerText == '待考试') {
				KECheng[i].parentElement.querySelector('td>a').click()
				break;
			}else if(i==KECheng.length-1){//全都看完了
                     window.location.replace('https://www.cmechina.net/cme/myHome.jsp')
                     }
		}

			}

    }
    setTimeout(Ggerenzhongxin,3424)

    function zidongSX(){
        if (document.URL.search("cme/myHome") > 1) {
        setTimeout(sx,60000*3)
        }
    }
    setTimeout(zidongSX,15454)

	function zy() {
		if (document.URL.search('cme/course.jsp') > 1) {
            localStorage.setItem('learning',document.URL);
			if (document.getElementsByClassName('xxz').length > 0) {
				document.getElementsByClassName('xxz')[0].click()
			}else {
				setTimeout(gbclose,245)
			}
		}
	}
	setTimeout(zy,5000)

	function ksy() { //考试界面
		if (document.URL.search('cme/exam.jsp') > 1) {
			var xuanxiang = document.querySelectorAll('ul.exam_list>li>p>input')
				for (var i = 0; i < xuanxiang.length; i++) {
					if (xuanxiang[i].type == 'radio' && xuanxiang[i].value == 'A') { //单选题
						xuanxiang[i].click()
					}
					if (xuanxiang[i].type == 'checkbox') { //多选全选ABCD
						xuanxiang[i].click()
					}
				}
				if (document.getElementsByClassName('cur').length == 1) {
					document.getElementsByClassName('cur')[0].click() //提交
				}
		}
	}
	//setTimeout(ksy,2000)

	function day() {
		if (document.URL.search('cme/examQuizFail') > 1) { //答题结果界面
            if(document.getElementsByClassName('cuo').length==0){
                window.location.replace(localStorage.getItem('learning'))
            }

			//返回

		}


	}

	setInterval(day, 2050)

	function pass() {

		if (document.URL.search('QuizPass') > 1) {
			localStorage.clear('key')
			document.querySelector('div.box>div.show_exam_btns>a').click()
		}
	}
	setTimeout(pass, 2000)

	function fh() {
		if(document.getElementsByTagName('video')[0].paused){
            if(document.querySelector('.ccH5TimeCurrent').innerText==document.querySelector('.ccH5TimeTotal').innerText){
                 setTimeout(function(){
                     window.location.replace(localStorage.getItem('learning'))
                 },4241)
            }
        }
		//setTimeout(djks, 4200)
	}
	setInterval(fh, 2000);

	function djks() {
		javascript: gotoExam();
	}
    setInterval(djks, 3000);
    function S申请学分(){
        if(document.querySelector("#jmessagebox_yesbutton")!==null){
        document.querySelector("#jmessagebox_yesbutton").click();
        }
        if(document.querySelector("body > div.popup-iphone").style[0]!=="display"){
        document.querySelector("body > div.popup-iphone").style="display: none;"
            window.scrollTo(0, document.body.scrollHeight);
                setTimeout(document.querySelector("#form2 > table>tbody>tr>td>input").click(),1121)
        }


    }
    setInterval(S申请学分, 2000);
    function F返回学分页(){
    if(document.querySelector("body > div div > div > a").innerText=="查看学分"){
           document.querySelector("body > div div > div > a").click()
        }
    }
    setInterval(F返回学分页, 1200);
})();