// ==UserScript== // @name 长沙理工普通作业 // @namespace http://tampermonkey.net/ // @version 0.02 // @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 GM_setClipboard // @grant unsafeWindow // @downloadURL none // ==/UserScript== (function() { 'use strict'; const umsg = (function () { const position = { 1: "bottom:-0.7em;left:7.2em;", 2: "bottom:-0.7em;left:50%;", 3: "bottom:-0.7em;right:-6.2em;", 4: "top:50%;left:7.2em;", 5: "top:50%;left:50%;", 6: "top:50%;right:-6.2em;", 7: "top:2em;left:7.2em;", 8: "top:2em;left:50%;", 9: "top:2em;right:-6.2em;" }; // prettier-ignore const show = (msg, duration, pos, bgc) => { let m = document.createElement("div"); const conf = umsg.conf; m.style.cssText = `background-color: ${bgc};${position[pos ?? conf.pos ?? 5]}` + "position: fixed;padding:10px 20px;z-index:99999;width: 200px;max-height: 70%;overflow: auto; color: white;word-break: break-all;text-align: center;border-radius: 5px;transform: translate(-50%, -50%);pointer-events: all;font-size: 15px;line-height: 1.5;box-sizing: border-box;"; m.style.cssText += conf.style ?? ""; m.innerHTML = msg; (conf.selector || document.body)?.appendChild(m); setTimeout(() => { let d = 0.5; m.style.transition = "transform " + d + "s ease-in, opacity " + d + "s ease-in"; m.style.webkitTransition = "-webkit-transform " + d + "s ease-in, opacity " + d + "s ease-in"; m.style.opacity = "0"; setTimeout(() => m.remove(), d * 1000); }, duration ?? conf.duration ?? 2000); }; return { conf: { duration: 2000, pos: 1, selector: document.body, style: "" }, info: (msg, duration, pos) => show(msg, duration, pos, "rgba(0, 0, 0, 0.77)"), success: (msg, duration, pos) => show(msg, duration, pos, "rgba(50, 198, 130, 0.77)"), warning: (msg, duration, pos) => show(msg, duration, pos, "rgba(238, 191, 49, 0.77)"), error: (msg, duration, pos) => show(msg, duration, pos, "rgba(255, 85, 73, 0.77)"), }; })(); function copyText(tex){ umsg.success("copy success", 600,8); GM_setClipboard(tex); } unsafeWindow.copyText=copyText; 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); } }else if (window.location.href.indexOf("exam/student/exam2/doexam") !== -1) { } 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) { document.querySelector("#ui_wrapper > div.ui-main > div.ui-iframe-wrapper > iframe").onload = () => { if (document.querySelector("#ui_wrapper > div.ui-main > div.ui-iframe-wrapper > iframe").contentWindow.document.querySelector("body > center > div.ui-paper-wrapper > h1").innerText.indexOf("期末") !== -1) { Array.from(document.querySelector("#ui_wrapper > div.ui-main > div.ui-iframe-wrapper > iframe").contentWindow.document.getElementsByClassName("ui-question")).forEach( e => { e.children[0].innerHTML=e.children[0].innerHTML+`` }) } else { answers = JSON.parse(window.prompt("输入JSON字符", "")) 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")]); }) } } 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; } } } 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 + `` }) }, 3000) } })();