继续教育自动答题

2022/5/31

目前為 2022-06-01 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        继续教育自动答题
// @namespace   Violentmonkey Scripts
// @match       *://pcourse.gzteacher.com/video/*
// @match       *://pcourse.gzteacher.com/booklcms/index/student/doMain.do
// @match       *://study.gzteacher.com/study/study
// @grant       none
// @version     1.5
// @author      -
// @description 2022/5/31 
// @license MIT
// ==/UserScript==


if(window.location.href.indexOf("study.gzteacher.com/study/study0000000")>0){
  console.log('load next...')
  // 如果视频播放完成了,则跳转到下一个:
  var sii = setInterval(function(){
    var testLayers = document.getElementsByClassName("test_layer");
    if(testLayers.length>0){
        if(testLayers[0].style.display=="block"){
            if (checkActStu(nextKonwId)) {
                var mc = document.getElementById("makeComment");
                var finish = true;
                if(mc){
                   // 需发表回复和评论
                   var fi = document.getElementById("myForumInfo");
                   var fr = document.getElementById("myForumReply");
                   if(fi.innerText == '0' || fr.innerText == '0'){
                       console.log('未完成')
                       //window.clearInterval(sii);  
                       finish = false;
                       return;
                   }
               }
              if(finish){
                  console.log('next show...')
                  $(".left_side").animate({top:"-999px"},1000);
                  if($(".left_side").css("top")!="-999px"){ 
                    childActIds = "";
                    setTimeout("nextLeftside()",1000);
                  }
               }   
			      } 
        }
    }
  }, 3000)
}else{ 
    console.log('check autoAnswer...')
     setTimeout(function () { 
          nextVideo();
    }, 3000);
    
}


function nextVideo(){
  //var modal = $(".ant-modal-content")
  var modal = document.getElementsByClassName("ant-modal-content")[0]
    if(modal){
        // 有弹窗
       modalButton = modal.getElementsByTagName("button");
       if(modalButton){
           // 弹窗上有按钮
           if(modalButton.length == 3){
               console.log('next video...')
              // 有3个按钮: 重新学习,下一活动,关闭
              // 点击下一活动
                 modalButton[1].click()
             }else{
                continueStudy();
            }
       }
    }
}

function continueStudy(){
    //var continueBtn = $(".ant-modal-content button")
    var continueBtn = document.getElementsByClassName("ant-modal-content")[0].getElementsByTagName("button")[0]
    if(continueBtn){ 
        console.log('continue play...')
        // 点击问答弹窗上的“继续学习”按钮
        continueBtn.click() 
    }
}

function autoAnswer(qaid){
  	console.log('autoAnswer start...qaid: ' + qaid); 
  	console.log('选择正确回答项');
		var api = frameElement.api, W = api.opener;

		W.qaMap.userResult = W.qaMap.ans;
		console.log('提交回答');
		if("undefined" == typeof showAns){ 
  			api.content.showAns();
		}else{
 				showAns();
		}
		console.log('继续学习');
		videoplayer.updateActivity(qaid,W.qaMap["status"], false); 
		console.log('关闭答题窗口');
		W.qaDialog.close();
		videoplayer.play()
}

function getQueryVariable(variable){
       var query = window.location.search.substring(1);
       var vars = query.split("&");
       for (var i=0;i<vars.length;i++) {
               var pair = vars[i].split("=");
               if(pair[0] == variable){return pair[1];}
       }
       return(false);
}