Greasy Fork

Greasy Fork is available in English.

长沙理工普通作业

长沙理工继续教育学院第一学期

目前为 2024-11-10 提交的版本。查看 最新版本

// ==UserScript==
// @name         长沙理工普通作业
// @namespace    http://tampermonkey.net/
// @version      0.01
// @license      MIT
// @description  长沙理工继续教育学院第一学期
// @author       HellSherry
// @match       *://*.edu-edu.com/*
// @match        https://csustcj.edu-edu.com.cn/System/OnlineLearningNew/OnlineLearningNewIndex*
// @match        https://csustcj.edu-edu.com.cn/MyOnlineCourseNew/OnlineLearningNew/OnlineLearningNewIndex*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=edu-edu.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

     if(window.location.href.indexOf("doview")!==-1){

          let answer={}
    var ifdoucument;

   document.querySelector("#ui_wrapper > div > div.ui-iframe-wrapper > iframe").onload=() => {
                setTimeout(() => {

      ifdoucument= document.querySelector("#ui_wrapper > div > div.ui-iframe-wrapper > iframe").contentWindow.document;

   Array.from(ifdoucument.getElementsByClassName("ui-correct-answer")).forEach(e=>{
  if( answer[e.parentElement.parentElement.getAttribute("code")]==undefined){
  answer[e.parentElement.parentElement.getAttribute("code")]= e.getAttribute("code");
  }else{
    answer[e.parentElement.parentElement.getAttribute("code")]+= e.getAttribute("code");
}


   })


     document.querySelector("#ui_wrapper").innerHTML= JSON.stringify(answer)

      Object.keys(answer).forEach(s=>{
          console.log(s)
          console.log(answer[s])
 //     fetch("http://localhost:8080/cslg/add?id="+s+"&answer="+answer[s])
  // .then(response => response.text())
   //.then(result => console.log(result))

      })}, 1000);
}




    }
var answers=
{"psq_1090560":"c","psq_1090561":"a","psq_1090562":"c","psq_1090563":"a","psq_1090564":"a","psq_1090565":"d","psq_1090566":"a","psq_1090567":"a","psq_1090568":"b","psq_1090569":"d","psq_1090570":"d","psq_1090571":"d","psq_1090572":"c","psq_1090573":"b","psq_1090574":"b","psq_1090575":"a","psq_1090576":"a","psq_1090577":"c","psq_1090578":"a","psq_1090579":"a","psq_1090580":"a","psq_1090581":"a","psq_1090582":"b","psq_1090583":"a","psq_1090584":"b","psq_1090585":"b","psq_1090586":"b","psq_1090587":"d","psq_1090588":"c","psq_1090589":"c","psq_1090590":"a","psq_1090591":"a","psq_1090592":"b","psq_1090593":"b","psq_1090594":"b","psq_1090595":"b","psq_1090596":"a","psq_1090597":"a","psq_1090598":"b","psq_1090599":"b"}
// Your code here...

    if(window.location.href.indexOf("doexam")!==-1){
        answers=JSON.parse( window.prompt("输入一个数字", ""))
         function clickElements(elem,nums) {
             elem.setAttribute("title",nums);

let ti=0
if(
nums.indexOf("参考答案")!==-1){
    nums=nums.replace("参考答案:", "")
      ti=300+ti;
               setTimeout(() => {
  elem.children[3].children[1].children[0].contentWindow.document.querySelector("body").innerText=nums
                   elem.children[3].children[1].children[0].contentWindow.document.querySelector("body").click()


   // elem.parentElement.onclick=function(){
  //  window.alert(nums);
   // }
}, ti);
}else {
            nums.split('').forEach(
     (s)=>{
         ti=300+ti;
             setTimeout(() => {

                 if( elem.lastElementChild.children[getNum(s)].className!=='ui-option-selected')elem.lastElementChild.children[getNum(s)].children[0].click();

}, ti);

      })
}
            setTimeout(() => {
                __ExamIns.offsetQuestion(1)
}, 100);

        }
    function getNum(num) {
    switch(num){
        case 'a':
            return 0;
        case 'b':
            return 1;
        case 'c':
            return 2;
        case 'd':
            return 3;
        case 'e':
            return 4;
        case 'f':
            return 5;
        case 'g':
            return 6;

    }
  }
    document.querySelector("#ui_wrapper > div.ui-main > div.ui-iframe-wrapper > iframe").onload=() => {

   Array.from( document.querySelector("#ui_wrapper > div.ui-main > div.ui-iframe-wrapper > iframe").contentWindow.document.getElementsByClassName("ui-question")).forEach(

    e=>{



if(answers[e.getAttribute("code")]!=null)clickElements(e,answers[e.getAttribute("code")]);


    })
 }

}
else if (window.location.href.indexOf("OnlineLearningNew/OnlineLearningNewIndex")!==-1){

  setTimeout(() => {
  Array.from(document.getElementsByClassName("single-lists")).forEach(e=>{
 let aa=e.children[1].children[0].children[0].children[0].getAttribute("onclick").toString()

  e.innerHTML= e.innerHTML+`<button onclick="window.open(
    'https://csustcj.edu-edu.com.cn/MyOnlineCourseNew/OnlineLearningNew/StudentSiteNewExIndex?termcourseID=`+aa.substring (aa.lastIndexOf(',')+2,aa.lastIndexOf("'"))+`&type=3#',
    '单独窗口',
    'height=30000,width=60000,top=0,left=0,toolbar=no,menubar=no, scrollbars=no,resizable=no,location=no, status=no'
  )">强制开始期末考试</button>`


  })
  },3000)


}


})();