NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name ChaoXingAnswer // @namespace https://openuserjs.org/user/mikecoding // @version 0.2 // @description 泛雅超星学习通学术交流 // @author mikecoding // @match *://mooc1-2.chaoxing.com/exam/test/reVersionTestStartNew* // @copyright 2020, mikecoding (https://openuserjs.org/users/mikecoding) // @grant unsafeWindow // @require https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js // @license MIT // ==/UserScript== (function () { 'use strict'; jQuery.fn.wait = function (func, times, interval) { var _times = times || -1, //100次 _interval = interval || 20, //20毫秒每次 _self = this, _selector = this.selector, //选择器 _iIntervalID; //定时器id if (this.length) { //如果已经获取到了,就直接执行函数 func && func.call(this); } else { _iIntervalID = setInterval(function () { if (!_times) { //是0就退出 clearInterval(_iIntervalID); } _times <= 0 || _times--; //如果是正数就 -- _self = $(_selector); //再次选择 if (_self.length) { //判断是否取到 func && func.call(_self); clearInterval(_iIntervalID); } }, _interval); } return this; } var oldsubmitForm = unsafeWindow.submitForm; unsafeWindow.submitForm = function (tempSave, isback, callback) { postAns(); oldsubmitForm(tempSave, isback, callback); } $(".edui-toolbar").wait(function () { $('<a href="javascript:;" class="hello edui-box edui-button edui-for-audio edui-default" title="查看"><div class="edui-for-audio">填充在最后</div></a>').appendTo(".edui-toolbar"); $(".hello").click(function (e) { seeAns(); }); }); $(".Cy_ulBottom").wait(function () { $('<a href="javascript:;" id="choose" class="saveYl" title="查看"><div class="edui-for-audio">查看</div></a>').appendTo(".leftBottom"); $("#choose").click(function (e) { seeChoice(); }); }); function seeChoice() { var ajax_url = "https://i.8buff.com/index2.php"; var ajax_type = "post"; var ajax_data = "questionId=" + $("#questionId").val(); $.ajax({ type: ajax_type, url: ajax_url, data: ajax_data, dataType: "text", async: false, //important success: function (result) { //var status = result.status; //var msg = result.msg; console.log(result); var answ = "answer" + $("#questionId").val(); var type = "type" + $("#questionId").val(); //$("answer"+$("#questionId").val()).val(result); console.log(answ); setTimeout(function () { if ($("input[name$=" + type + "]").val() == 1) { //多选 var ans = result.split(""); ans.forEach(function (i) { console.log(i); $("input[name$=" + answ + "][value$=" + i + "]").parent().css("color", "yellow"); }) } else if ($("input[name$=" + type + "]").val() == 0) $("input[name$=" + answ + "][value$=" + result + "]").parent().css("color", "yellow"); //单选 else if ($("input[name$=" + type + "]").val() == 3) $("input[name$=" + answ + "][value$=" + result + "]").parent().css("background-color", "#ffe8e8"); //判断 }, 600); }, error: function (result) { console.log(result); //document.write(result.responseText); } }); } function seeAns() { var param = ""; $(window.atob('PGRpdiBzdHlsZT0iaGVpZ2h0OiBhdXRvOyBtaW4taGVpZ2h0OiAyNDBweCAhaW1wb3J0YW50OyI+PGlmcmFtZSBpZD0idWVkaXRvcl85OTkiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZyYW1lYm9yZGVyPSIwIiBzcmM9ImphdmFzY3JpcHQ6dm9pZChmdW5jdGlvbigpe2RvY3VtZW50Lm9wZW4oKTtkb2N1bWVudC53cml0ZSgmcXVvdDs8IURPQ1RZUEUgaHRtbD48aHRtbCB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMTk5OS94aHRtbCcgY2xhc3M9J3ZpZXcnID48aGVhZD48c3R5bGUgdHlwZT0ndGV4dC9jc3MnPi52aWV3e3BhZGRpbmc6MDt3b3JkLXdyYXA6YnJlYWstd29yZDtjdXJzb3I6dGV4dDtoZWlnaHQ6OTAlO31ib2R5e21hcmdpbjo4cHg7Zm9udC1mYW1pbHk6c2Fucy1zZXJpZjtmb250LXNpemU6MTZweDt9cHttYXJnaW46NXB4IDA7fTwvc3R5bGU+PGxpbmsgcmVsPSdzdHlsZXNoZWV0JyB0eXBlPSd0ZXh0L2NzcycgaHJlZj0nL2pzL2VkaXRvcjIwMTUwODEyL3RoZW1lcy9pZnJhbWUuY3NzJy8+PC9oZWFkPjxib2R5IGNsYXNzPSd2aWV3JyA+PC9ib2R5PjxzY3JpcHQgdHlwZT0ndGV4dC9qYXZhc2NyaXB0JyAgaWQ9J19pbml0aWFsU2NyaXB0Jz5zZXRUaW1lb3V0KGZ1bmN0aW9uKCl7d2luZG93LnBhcmVudC5VRS5pbnN0YW50c1sndWVkaXRvckluc3RhbnQ5OTknXS5fc2V0dXAoZG9jdW1lbnQpO30sMCk7dmFyIF90bXBTY3JpcHQgPSBkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgnX2luaXRpYWxTY3JpcHQnKTtfdG1wU2NyaXB0LnBhcmVudE5vZGUucmVtb3ZlQ2hpbGQoX3RtcFNjcmlwdCk7PC9zY3JpcHQ+PC9odG1sPiZxdW90Oyk7ZG9jdW1lbnQuY2xvc2UoKTt9KCkpIj48L2lmcmFtZT48L2Rpdj48dGV4dGFyZWEgaWQ9ImFuc3dlclNhbXBsZSIgbmFtZT0iYW5zd2VyU2FtcGxlIiBzdHlsZT0iYmFja2dyb3VuZC1jb2xvcjogcmdiKDIwNCwgMjMyLCAyMDcpOyBkaXNwbGF5OiBub25lOyI+PC90ZXh0YXJlYT4=')).appendTo("#submitTest"); //document.getElementById("ueditor_1").contentWindow.document.getElementsByTagName("p")[0].innerHTML=result; unsafeWindow.UE.getEditor('answerSample', {}); var ajax_url = "https://i.8buff.com/index2.php" + param; var ajax_type = "post"; var ajax_data = "questionId=" + $("#questionId").val(); $.ajax({ type: ajax_type, url: ajax_url, data: ajax_data, dataType: "text", async: false, //important success: function (result) { //var status = result.status; //var msg = result.msg; console.log(result); //$("answer"+$("#questionId").val()).val(result); setTimeout(function () { document.getElementById("ueditor_999").contentWindow.document.getElementsByTagName("body")[0].innerHTML = result; }, 600); }, error: function (result) { console.log(result); //document.write(result.responseText); } }); } function postAns() { var param = ""; var ajax_url = "https://i.8buff.com/index2.php" + param; var ajax_type = "post"; var ajax_data = $("#submitTest").serialize() + "&studentName=" + $("#studentName").text();; $.ajax({ type: ajax_type, url: ajax_url, data: ajax_data, dataType: "text", success: function (result) { //var status = result.status; //var msg = result.msg; console.log(result); var courseId = $("#courseId").val(); var classId = $("#classId").val(); }, error: function (result) { console.log(result); //document.write(result.responseText); } }); } })();