云班课🆕答题小能手🥇【开源版】

【😎蓝墨云全自动答题,一键完成所有资源学习😎】、【🧡功能全部免费使用🧡】【🔥抵制网络答题考核制度⚡️,🌵学生的平时成绩不应由简单的题目判定🌵,更不是依靠搜索引擎🔥】,【欢迎加入qq群:😄947446522😄,共同交流进步】。【💚作者在此保证,脚本无任何诸如(手机号,学校信息,等隐私信息收集)💚】

  1. // ==UserScript==
  2. // @name 云班课🆕答题小能手🥇【开源版】
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.8
  5. // @description 【😎蓝墨云全自动答题,一键完成所有资源学习😎】、【🧡功能全部免费使用🧡】【🔥抵制网络答题考核制度⚡️,🌵学生的平时成绩不应由简单的题目判定🌵,更不是依靠搜索引擎🔥】,【欢迎加入qq群:😄947446522😄,共同交流进步】。【💚作者在此保证,脚本无任何诸如(手机号,学校信息,等隐私信息收集)💚】
  6. // @author 阿绿
  7. // @note 致谢表:@Pumpkin、@小陈陈陈陈啊、@Sli、@无心人、@29827*0049、@热心解答(以上均是对此脚本做出过有效BUG提交OR提供账户帮助修复OR提供好的idea,如有遗漏请告知)
  8. // @supportURL https://gf.qytechs.cn/scripts/462689-%E4%BA%91%E7%8F%AD%E8%AF%BE%E7%AD%94%E9%A2%98%E5%8A%A9%E6%89%8B/code/%E4%BA%91%E7%8F%AD%E8%AF%BE%E7%AD%94%E9%A2%98%E5%8A%A9%E6%89%8B.user.js
  9. // @homepageURL https://gf.qytechs.cn/scripts/462689-%E4%BA%91%E7%8F%AD%E8%AF%BE%E7%AD%94%E9%A2%98%E5%8A%A9%E6%89%8B/code/%E4%BA%91%E7%8F%AD%E8%AF%BE%E7%AD%94%E9%A2%98%E5%8A%A9%E6%89%8B.user.js
  10. // @match https://www.mosoteach.cn/web/index.php?*
  11. // @icon https://bkimg.cdn.bcebos.com/pic/4ec2d5628535e5dde7114110e88eb0efce1b9c16c4e1
  12. // @require https://cdn.bootcss.com/crypto-js/3.1.9-1/crypto-js.min.js
  13. // @require https://gf.qytechs.cn/scripts/463249-%E4%BA%91%E7%8F%AD%E7%8F%AD%E4%BE%9D%E8%B5%96/code/%E4%BA%91%E7%8F%AD%E7%8F%AD%E4%BE%9D%E8%B5%96.js?version=1170857
  14. // @grant GM_setValue
  15. // @grant GM_getValue
  16. // @grant GM_addStyle
  17. // @grant GM_xmlhttpRequest
  18. // @connect 121.37.103.75
  19. // @connect gitee.com
  20. // @connect *
  21. // @license MIT
  22. // ==/UserScript==
  23.  
  24. ;(function(_this) {
  25. function MyPage(menu){
  26. // time = Math.floor(Date.now()/10000);
  27. // time = time %16;
  28. // console.log(time)
  29. // // this.axios = _this.axios;
  30. // // this.Qs =Qs;
  31. this.$ = $;
  32. this.json = _this.JSON
  33. this.namespace = menu.id;
  34. this.menu = menu;
  35. this.config = {};
  36. this.config.tk_uid =null;
  37. this.initMenu();
  38. // this.initVue();
  39. return this;
  40. }
  41. MyPage.prototype.urlToObject = function(url){
  42. let obj = {}
  43. let arr1 = url.split("?")
  44. let arr2 = arr1[1].split("&")
  45. for(let i=0;i<arr2.length;i++){
  46. let res = arr2[i].split("=")
  47. obj[res[0]]=res[1]
  48. }
  49. return obj;
  50. }
  51.  
  52. // MyPage.prototype.guid= function(data){
  53. // return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  54. // var r =Math.random() * 16 | 0,
  55. // v = c == 'x' ? r : (r & 0x3 | 0x8);
  56. // console.log(v);
  57. // return v.toString(16);
  58. // });
  59. // }
  60. MyPage.prototype.upladApi = function(url,data){
  61. var obj={};
  62. obj.poolId = this.config.poolId;
  63. obj.token = "06e599f3-78db-4c71-b4fa-2b496beab1f6";
  64. for(var key in data){
  65. obj[key] = data[key];
  66. }
  67. return new Promise(function(resolve, reject){
  68. GM_xmlhttpRequest({
  69. timeout: 10000,
  70. method: "post",
  71. "url": url,
  72. headers:{
  73. "Content-Type":'application/json',
  74. accept: "application/json",
  75. },
  76. data: JSON.stringify(obj),
  77. onload: function(response) {
  78. var status = response.status;
  79. var playurl = "";
  80. var responseText = response.responseText;
  81. if(status==200||status=='200'||status==501||status=='501'||status==400||status=='400'){
  82. resolve({"result":"success", "json":responseText});
  83. }else{
  84. //resolve({"result":"success", "json":responseText});
  85. reject({"result":"error", "json":responseText});
  86. }
  87. },
  88. onerror : function(err){
  89. console.log('error')
  90. console.log(err)
  91. },
  92. ontimeout : function(inf){
  93. if(url != "http://121.37.103.75:10086/tiku/api/v1/problems"){
  94. console.log('请求超时')
  95. console.log(inf)
  96. let aner = $('body').find("#aner")
  97. aner.css("display","block")
  98. aner.text("服务器响应超时,请稍后重试,或者直接加群,来催更。");
  99. }
  100. }
  101. });
  102. });
  103. }
  104. MyPage.prototype.HtmlUtil = {
  105. /*1.用浏览器内部转换器实现html转码*/
  106. htmlEncode:function (html){
  107. //1.首先动态创建一个容器标签元素,如DIV
  108. var temp = document.createElement ("div");
  109. //2.然后将要转换的字符串设置为这个元素的innerText(ie支持)或者textContent(火狐,google支持)
  110. (temp.textContent != undefined ) ? (temp.textContent = html) : (temp.innerText = html);
  111. //3.最后返回这个元素的innerHTML,即得到经过HTML编码转换的字符串了
  112. var output = temp.innerHTML;
  113. temp = null;
  114. return output;
  115. },
  116. /*2.用浏览器内部转换器实现html解码*/
  117. htmlDecode:function (text){
  118. //1.首先动态创建一个容器标签元素,如DIV
  119. var temp = document.createElement("div");
  120. //2.然后将要转换的字符串设置为这个元素的innerHTML(ie,火狐,google都支持)
  121. temp.innerHTML = text;
  122. //3.最后返回这个元素的innerText(ie支持)或者textContent(火狐,google支持),即得到经过HTML解码的字符串了。
  123. var output = temp.innerText || temp.textContent;
  124. temp = null;
  125. return output;
  126. }
  127. };
  128.  
  129. MyPage.prototype.resoluAnswers=function(data){
  130. let newData = {};
  131. if(data ==null){
  132. return console.log("并未获取到题库数据");
  133. }
  134. if("activity" in data){
  135. console.log("蓝墨云题库重组中");
  136. newData.id = data.activity.id;
  137. newData.title = data.activity.title;
  138. newData.rows = [];
  139. data.activity.topics.forEach(row=>{
  140. let _data = {};
  141. _data.id = row.topic_id;
  142. row.subject=this.HtmlUtil.htmlDecode(row.subject);
  143. _data.subject = row.subject;
  144. _data.options = [];
  145. _data.answers = [];
  146. _data.type = row.type;
  147. if(row.type == "TF"){
  148. if(row.tf_answer!=null){
  149. _data.answers.push(row.tf_answer);
  150. }else{
  151. if(row.result == 1){
  152. _data.answers.push(row.user_tf_answer)
  153. }else{
  154. _data=null;
  155. }
  156. }
  157. }else if(row.type == "FILL"){
  158. row.fill.blank_alternatives.forEach(answer=>{
  159. if(answer.contents[0] !=null){
  160. _data.answers.push(answer.contents);
  161. }else{
  162. if(answer.result ==1){
  163. _data.answers.push(answer.user_content)
  164. }else{
  165. _data=null;
  166. }
  167. }
  168. });
  169. }else{
  170. if(row.answers.length != 0){
  171. row.answers.forEach(index =>{
  172. row.options.forEach(option=>{
  173. _data.options.push(this.HtmlUtil.htmlDecode(option.content));
  174. if(option.item_no == index){
  175. _data.answers.push(this.HtmlUtil.htmlDecode(option.content));
  176. }
  177. });
  178. });
  179. }else{
  180. if(row.result == 1){
  181. row.user_answers.forEach(index =>{
  182. row.options.forEach(option=>{
  183. _data.options.push(this.HtmlUtil.htmlDecode(option.content));
  184. if(option.item_no == index){
  185. _data.answers.push(this.HtmlUtil.htmlDecode(option.content));
  186. }
  187. });
  188. });
  189. }else{
  190. _data=null;
  191. }
  192. }
  193. }
  194. if(_data != null){
  195. newData.rows.push(_data);
  196. }
  197. });
  198. }else if("paperId" in data){
  199. console.log("meto题库重组中");
  200. newData.id = data.title;
  201. newData.rows = [];
  202. data.problems.forEach(row=>{
  203. let _data ={};
  204. _data.subject = row.text;
  205. _data.answers = JSON.parse(row.answer);
  206. newData.rows.push(_data);
  207. });
  208. }else if("rule" in data){
  209. console.log("助手题库重组中");
  210. newData.rows = [];
  211. if("get_answer" in data){ //修改未测试
  212. data.get_answer.forEach(row=>{
  213. let _data ={};
  214. _data.answers = [];
  215. let br = new RegExp("-and-","g");
  216. row.t = row.t.replace(br,"&");
  217. row.t=this.HtmlUtil.htmlDecode(row.t);
  218. _data.subject = row.t;
  219. row.a.forEach(an=>{
  220. _data.answers.push(this.HtmlUtil.htmlDecode(an.replace(br,"&")))
  221. })
  222. _data.type =row.y;
  223. _data.options = row.s;
  224. newData.rows.push(_data);
  225. });
  226. }
  227. }else if("flag" in data){
  228. if (data.flag == "metoproblems"){
  229. console.log("meto1题组重组中");
  230. newData.id = data.title;
  231. newData.rows = [];
  232. try{
  233. data.problems.forEach(row=>{
  234. let _data ={};
  235. _data.subject = row.text;
  236. _data.answers = JSON.parse(row.answer);
  237. newData.rows.push(_data);
  238. });
  239. }catch (e){
  240. // alert("服务器连接失败,请联系作者。")
  241. console.log("发生异常:" + e);
  242. }
  243. }
  244. }else{
  245. console.log("题库格式未识别");
  246. console.log(data);
  247. }
  248. console.log(newData)
  249. return newData;
  250. }
  251. /*
  252. * 云班课请求
  253. */
  254.  
  255. MyPage.prototype.getListMember = function(clazzcourseId){
  256. return new Promise((resolve,rejcet)=>{
  257. this.$.ajax({
  258. type: 'post',
  259. url:"https://www.mosoteach.cn/web/index.php?c=member&m=get_list_member",
  260. dataType:"json",
  261. data: {
  262. clazz_course_id: clazzcourseId,
  263. order_item: 'score'
  264. },
  265. success: function(res) {
  266. resolve(res.data.member_data);
  267. }
  268. });
  269. });
  270. }
  271. MyPage.prototype.personResult = function(id,userId,ccId){
  272. return new Promise((resolve,rejcet)=>{
  273. this.$.ajax({
  274. type: 'post',
  275. url:"https://www.mosoteach.cn/web/index.php?c=interaction_quiz&m=person_result",
  276. dataType:"json",
  277. data: {
  278. id: id,
  279. user_id: userId,
  280. cc_id: ccId,
  281. },
  282. success: function(res) {
  283. resolve(res);
  284. }
  285. });
  286. });
  287. }
  288. MyPage.prototype.join_class=function(){
  289. return new Promise((resolve,rejcet)=>{
  290. this.$.ajax({
  291. type: 'post',
  292. url:"https://www.mosoteach.cn/web/index.php?c=clazzcourse&m=my_joined",
  293. dataType:"json",
  294. success: function(res) {
  295. resolve(res.data);
  296. }
  297. });
  298. });
  299. }
  300.  
  301. MyPage.prototype.get_page=function(class_id){
  302. return new Promise((resolve,rejcet)=>{
  303. this.$.ajax({
  304. type: 'post',
  305. url:"https://www.mosoteach.cn/web/index.php?c=interaction&m=index&clazz_course_id="+class_id,
  306. success: function(res) {
  307. resolve(res);
  308. }
  309. });
  310. });
  311. }
  312.  
  313. MyPage.prototype.get_page_status=function(id,ccId){
  314. return new Promise((resolve,rejcet)=>{
  315. this.$.ajax({
  316. type: 'post',
  317. url:"https://www.mosoteach.cn/web/index.php?c=interaction_quiz&m=get_quiz_ranking",
  318. dataType:"json",
  319. data: {
  320. id: id,
  321. ccId: ccId,
  322. },
  323. success: function(res) {
  324. resolve(res);
  325. }
  326. });
  327. });
  328. }
  329.  
  330. MyPage.prototype.x_res = function(reslist){
  331. var watch = reslist[0]
  332. var req = {}
  333. if (reslist.length != 0) {
  334. $("#x_res").text("剩下" + reslist.length + "个")
  335. } else {
  336. $("#x_res").text("全部完成")
  337. location.reload()
  338. return 0
  339. }
  340. var clazz_course_id = this.config.clazz_course_id
  341. $.ajax({
  342. type: "POST",
  343. url: "https://www.mosoteach.cn/web/index.php?c=res&m=request_url_for_json",
  344. data: {
  345. 'file_id': watch.id,
  346. 'type': 'VIEW',
  347. 'clazz_course_id': clazz_course_id,
  348. },
  349. dataType: "json",
  350. success: msg => {
  351. const src = msg.src
  352. if (src.indexOf("m3u8") > -1) {
  353. fetch(src)
  354. .then(data => data.text())
  355. .then(text => {
  356. let time = 0
  357. for (i of text.split("\n")) {
  358. if (i.indexOf("#EXTINF:") > -1) {
  359. i = parseFloat(i.replace("#EXTINF:", ""))
  360. time += i
  361. }
  362. }
  363. time = Math.ceil(time)
  364. $.ajax({
  365. type: 'post',
  366. dataType: 'json',
  367. url: 'https://www.mosoteach.cn/web/index.php?c=res&m=save_watch_to',
  368. data: {
  369. clazz_course_id: clazz_course_id,
  370. res_id: watch.id,
  371. watch_to: time,
  372. duration: time,
  373. current_watch_to: time
  374. },
  375. success: res => {
  376. reslist.splice(0, 1)
  377. this.x_res(reslist)
  378. }
  379. });
  380. })
  381. } else {
  382. reslist.splice(0, 1)
  383. this.x_res(reslist)
  384. }
  385. }
  386. })
  387. }
  388.  
  389. MyPage.prototype.getAnswers = async function(id,deep){
  390. let answers = {};
  391. let obj={
  392. "poolId": this.config.poolId,
  393. "token": "06e599f3-78db-4c71-b4fa-2b496beab1f6",
  394. "userId": this.config.tk_uid,
  395. "querry": {
  396. "operator": "==",
  397. "argument1": "papertitle",
  398. "argument2": id,
  399. },
  400. "deep": deep,
  401. };
  402. await(this.upladApi("http://121.37.103.75:10086/tiku/api/v1/queryCollection",obj).then(async (resutData)=>{
  403. if(resutData.result==="success" && !!resutData.json){
  404. var data = JSON.parse(resutData.json).results;
  405. console.log("总共查询到数据库数量"+data.length+"个");
  406. data.forEach((item, index) =>{
  407. if(index == 0){
  408. answers =this.resoluAnswers(item);
  409. }else{
  410. this.resoluAnswers(item).rows.forEach(i =>{
  411. answers.rows.push(i);
  412. })
  413. }
  414. });
  415. // if(this.config.answers == null ||this.config.answers.rows == false){
  416. // console.log("尝试查询题库2");
  417. // let obj={
  418. // "action": "get_answer",
  419. // "url": "https://www.mosoteach.cn/web/index.php?c=interaction_quiz&m=reply&id="+this.config.id,
  420. // "question": [],
  421. // "userId": "rand",
  422. // "exam": {
  423. // "limit": false,
  424. // "see_answer": true
  425. // },
  426. // "LiuLiuDaShun1234": true
  427. // };
  428. // await(this.upladApi("https://eb28743a-0a36-4e14-a166-160855f57610.bspapp.com/http/search",obj).then((resutData)=>{
  429. // if(resutData.result==="success" && !!resutData.json){
  430. // var data = JSON.parse(resutData.json).result;
  431. // this.config.answers = this.resoluAnswers(data);
  432.  
  433. // if( !("answers" in this.config)||this.config.answers.rows == false){
  434. // console.log("未查询到数据");
  435. // return null;
  436. // }
  437. // let obj={
  438. // "poolId": this.config.poolId,
  439. // "token": "06e599f3-78db-4c71-b4fa-2b496beab1f6",
  440. // "userId": this.config.tk_uid,
  441. // "tags":["网络"],
  442. // //"tags":[this.config.answers.title,"云班课"],
  443. // "title":this.config.id,
  444. // "problems":[],
  445. // };
  446. // data={};
  447. // this.config.answers.rows.forEach(row=>{
  448. // data={
  449. // "tags": ["网络"],
  450. // "text": row.subject,
  451. // "answer": JSON.stringify(row.answers),
  452. // };
  453. // data.tags.push(row.type);
  454. // let l = ["choice_A","choice_B","choice_C","choice_D","choice_E","choice_F","choice_G","choice_H","choice_I","choice_J","choice_K","choice_L","choice_M","choice_N","choice_O","choice_P","choice_Q","choice_R","choice_S","choice_T","choice_U","choice_V","choice_W","choice_X","choice_Y","choice_Z"];
  455. // let i=0;
  456. // row.options.forEach(option =>{
  457. // data[l[i]]=option;
  458. // i=i+1;
  459. // })
  460. // obj.problems.push(data);
  461. // });
  462. // this.upladApi("http://121.37.103.75:10086/tiku/api/v1/problems",obj).then((resutData)=>{
  463. // if(resutData.result==="success" && !!resutData.json){
  464. // var data = JSON.parse(resutData.json).data;
  465. // console.log(data);
  466. // }
  467. // });
  468. // }
  469. // }));
  470. // }
  471. }
  472. }));
  473.  
  474. return answers;
  475. }
  476. MyPage.prototype.getCookie = function(objName) { //获取指定名称的cookie的值
  477. var arrStr = document.cookie.split("; ");
  478. for (var i = 0; i < arrStr.length; i++) {
  479. var temp = arrStr[i].split("=");
  480. if (temp[0] == objName) return temp[1]; //解码
  481. }
  482. return "";
  483. }
  484.  
  485. MyPage.prototype.arrowMove = function(e){
  486. // 元素大小
  487. let elW = e.currentTarget.offsetWidth
  488. let elH = e.currentTarget.offsetHeight
  489. // 元素位置
  490. let elL = e.currentTarget.offsetLeft
  491. let elT = e.currentTarget.offsetTop
  492. // 鼠标位置
  493. let x = e.clientX
  494. let y = e.clientY
  495. // 窗口大小
  496. let w = window.innerWidth
  497. let h = window.innerHeight
  498. // 鼠标到元素左边距离
  499. let moveX = x - elL
  500. let moveY = y - elT
  501. let el = e.currentTarget
  502. document.onmousemove = function (e) {
  503. el.style.position = 'fixed';
  504. el.style.left = e.clientX -moveX + 'px'
  505. el.style.top =e.clientY - moveY + 'px'
  506. }
  507. document.onmouseup = function (e) {
  508. document.onmousemove = null
  509. document.onmouseup = null
  510. }
  511. };
  512.  
  513. MyPage.prototype.initMenu = function(){
  514. let $ = this.$,menu = this.menu;
  515. $(document).on('mousedown','#aner', function (e) {
  516. window.my.arrowMove(e);
  517. });
  518. $(document).on('click', '#x_start', function () {
  519. window.my.start();
  520. });
  521. $(document).on('click', '#x_set', function () {
  522. $('body').find("#set").toggle('active');
  523. });
  524. $(document).on('click', '#x_find',async function () {
  525. let aner = $('body').find("#aner")
  526. let text = document.getElementById("find_input")
  527. aner.css("display","block")
  528. aner.text("");
  529. if(text.value.length <10){
  530. aner.append("搜索题目需要10个字符以上");
  531. return;
  532. }
  533. aner.append("若长时间未返回信息,请反馈<hr>");
  534. // problem = window.my.HtmlUtil.htmlDecode(text.value);
  535. // console.log(problem)
  536. await window.my.findproblem(text.value.replace(/ /g,"   "))
  537. aner.text("");
  538. aner.append("搜索到"+window.my.config.answer.rows.length+"条相关题目<hr>");
  539. window.my.config.answer.rows.forEach(row=>{
  540. aner.append("题目:"+row.subject+"<br>"+"答案:");
  541. row.answers.forEach(answer =>{
  542. aner.append(answer+" ");
  543. });
  544. aner.append("<hr>");
  545. });
  546. });
  547. $(document).on('click', '#x_yue', async function () {
  548. let aner = $('body').find("#aner")
  549. aner.css("display","block")
  550. $("#x_yue").attr("disabled", true)
  551. aner.text("正在搜索答案中");
  552. let answers = await(window.my.getAnswers(window.my.config.id,true));
  553. if(!answers||JSON.stringify(answers) == "{}"){
  554. aner.text("暂时未收录此题,若可直接查看答案,进入查看题目答案页面,将自动收录答案信息");
  555. return;
  556. }
  557. aner.text("");
  558. answers.rows.forEach(row=>{
  559. aner.append("题目:"+row.subject+"<br>"+"答案:");
  560. row.answers.forEach(answer =>{
  561. aner.append(answer+" ");
  562. });
  563. aner.append("<hr>");
  564. });
  565. });
  566. $(document).on('click', '#x_res', async function () {
  567. $("#x_res").attr("disabled", true)
  568. var reslist = []
  569. $(".res-row-open-enable").each(function() {
  570. if ($(this).find('span[data-is-drag]')[0].dataset.isDrag == "N") {
  571. reslist.push({
  572. id: $(this).attr('data-value'),
  573. state: $(this).find('span[data-is-drag]')[0].dataset.isDrag,
  574. type: $(this).attr('data-mime')
  575. })
  576. }
  577. });
  578. window.my.x_res(reslist)
  579. });
  580. /**
  581. * MosoteachHelper CSS
  582. */
  583. const styleTag = `
  584. <style>
  585. #${menu.id} #zhu button{
  586. width: 130px;
  587. height: 40px;
  588. background: linear-gradient(to bottom, #4eb5e5 0%,#389ed5 100%); /* W3C */
  589. border: none;
  590. border-radius: 5px;
  591. position: relative;
  592. border-bottom: 4px solid #2b8bc6;
  593. color: #fbfbfb;
  594. font-weight: 600;
  595. font-family: 'Open Sans', sans-serif;
  596. text-shadow: 1px 1px 1px rgba(0,0,0,.4);
  597. font-size: 15px;
  598. text-align: left;
  599. text-indent: 5px;
  600. box-shadow: 0px 3px 0px 0px rgba(0,0,0,.2);
  601. cursor: pointer;
  602. /* Just for presentation */
  603. display: block;
  604. //margin: 0 0 0 12px;
  605. }
  606. #${menu.id} #zhu button:active {
  607. box-shadow: 0px 2px 0px 0px rgba(0,0,0,.2);
  608. top: 1px;
  609. }
  610. #${menu.id} #zhu button:after {
  611. content: "";
  612. width: 0;
  613. height: 0;
  614. display: block;
  615. border-top: 20px solid #187dbc;
  616. border-bottom: 20px solid #187dbc;
  617. border-left: 16px solid transparent;
  618. border-right: 20px solid #187dbc;
  619. position: absolute;
  620. opacity: 0.6;
  621. right: 0;
  622. top: 0;
  623. border-radius: 0 5px 5px 0;
  624. }
  625. #${menu.id}{
  626. text-align:center;
  627. width:0;
  628. height:0;
  629. position:fixed;
  630. left:${menu.pos.x}px;
  631. top:${menu.pos.y}px;
  632. background:${menu.background};
  633. opacity:${menu.opacity};
  634. }
  635. #${menu.id} .drawer{
  636. max-height:200px;
  637. overflow:auto;
  638. text-align:left;
  639. display: none;
  640. background: #fff;
  641. border-radius: 10px;
  642. box-shadow: 0 5px 15px rgba(0,0,0,0.2);
  643. width: 240px; /* initially */
  644. opacity: 0.9;
  645. z-index: 199;
  646. padding:3px;
  647. margin:10px;
  648. }
  649. #${menu.id} .drawer p{
  650. text-align:left;
  651. padding-left:5px;
  652. }
  653. #${menu.id} .drawer p button{
  654.  
  655. }
  656. </style>`;
  657. $(styleTag).appendTo('head');
  658. let $menu = $(
  659. `<div id='${menu.id}'>
  660. <div id="zhu">
  661. <button id="x_set">设置界面</button>
  662. </div>
  663. <div class= "drawer" id="set">
  664. <p>
  665. 用户<input id = "tiku_user" readonly="readonly" value="未获取到用户名,请刷新重试" />
  666. </p>
  667. <p>
  668. 题目<input id = "find_input" placeholder="搜索题目需要10个字符以上" />&nbsp<button id="x_find" >搜索</button>
  669. </p>
  670. <p>
  671. 如遇到答案未显示,未加载,未标红,等等问题,请加qq群:286997695反馈
  672. </p>
  673. </div>
  674. <div class= "drawer" id="aner">
  675. <p>
  676. 正在获取试卷中,请稍等
  677. </p>
  678. </div>
  679. </div>`);
  680. $('body').append($menu);
  681. }
  682.  
  683. MyPage.prototype.initData = async function(){ //初始化
  684. this.config = this.urlToObject(window.location.href);
  685. this.config.tk_uid=GM_getValue("ti_uid");
  686. this.config.pp = GM_getValue("pp");
  687. this.config.poolId = GM_getValue("poolId");
  688. if(!this.config.tk_uid || !this.config.pp || !this.config.poolId){
  689. let classListData = await (this.join_class());
  690. if(classListData.length == 0){
  691. return console.log("未登录(不可用)账户");
  692. }
  693. GM_setValue("ccid",classListData[0].id);
  694. let {data:objectList} = await (this.getListMember(classListData[0].id));
  695. if(objectList.length <= 0 ){
  696. return alert("初始化脚本失败");
  697. }
  698. this.config.user_id = objectList[0].user_id;
  699. this.config.user_list = objectList;
  700. // console.log(this.config.user_list)
  701. this.config.full_name = objectList[0].full_name;
  702. this.config.clazz_course_id = classListData[0].id
  703. let obj={
  704. "unionid": objectList[0].user_id,
  705. "username": objectList[0].full_name,
  706. "grade": "云班课",
  707. };
  708. await(this.upladApi("http://121.37.103.75:10086/tiku/api/v1/userInfo",obj).then((resutData)=>{
  709. if(resutData.result==="success" && !!resutData.json){
  710. var data = JSON.parse(resutData.json).data;
  711. if(data != null){
  712. if("message" in data){
  713. data.message = data.message.slice(1,-1).split(", ");
  714. this.config.tk_uid = data.message[0]
  715. this.config.pp = data.message[1]
  716. //生成poolid
  717. this.config.poolId = CryptoJS.MD5(CryptoJS.MD5(this.config.user_id).toString() + this.config.pp).toString();
  718. this.config.poolId = this.config.poolId.slice(0,8)+"-"+this.config.poolId.slice(8,12)+"-"+this.config.poolId.slice(12,16)+"-"+this.config.poolId.slice(16,20)+"-"+this.config.poolId.slice(20,32)
  719. GM_setValue("poolId",this.config.poolId);
  720. //
  721. GM_setValue("ti_uid",this.config.tk_uid);
  722. GM_setValue("pp",this.config.pp);
  723. // document.cookie = "ti_uid="+this.config.tk_uid+";max-age="+60 * 60 * 3;
  724. }
  725. }
  726. }
  727. }));
  728.  
  729. }
  730. document.getElementById("tiku_user").value=this.config.tk_uid;
  731.  
  732. if(this.config.m === "reply"||this.config.m === "person_quiz_result"){
  733. $('#zhu').append("<button id='x_start' >开始搜题</button>");
  734. // document.getElementById("zhu")
  735. }
  736. if(this.config.c === "res"){
  737. $('#zhu').append("<button id='x_res' >一键完成资源</button>");
  738. }
  739. if(this.config.m === "quiz_ranking" || this.config.m === "start_quiz_confirm"){
  740. $('#zhu').append("<button id='x_yue' >提前阅卷</button>");
  741. }
  742. if(this.config.m === "person_quiz_result"){
  743. if(!GM_getValue(this.config.id)){
  744. this.get_quiz_result(this.config.id,this.config.user_id,this.config.clazz_course_id);
  745. }
  746. }
  747. }
  748.  
  749. MyPage.prototype.get_quiz_result=async function(id,user_id,clazz_course_id){
  750. if(this.config.tk_uid == null);
  751. let res = await (this.personResult(id,user_id,clazz_course_id));
  752. // if(res.result_code != 0){
  753. // return alert(res.result_msg);
  754. // }
  755. answers = this.resoluAnswers(res);
  756. if(answers == null){
  757. _this.dumpData = this.config;
  758. return;
  759. }
  760. let obj={
  761. "poolId": this.config.poolId,
  762. "token": "06e599f3-78db-4c71-b4fa-2b496beab1f6",
  763. "userId": this.config.tk_uid,
  764. "tags":[answers.title,"云班课"],
  765. "title":answers.id,
  766. "problems":[],
  767. };
  768. let data={};
  769. answers.rows.forEach(row=>{
  770. data={
  771. "tags": ["云班课"],
  772. "text": row.subject,
  773. "answer": JSON.stringify(row.answers),
  774. };
  775. data.tags.push(row.type);
  776. let l = ["choice_A","choice_B","choice_C","choice_D","choice_E","choice_F","choice_G","choice_H","choice_I","choice_J","choice_K","choice_L","choice_M","choice_N","choice_O","choice_P","choice_Q","choice_R","choice_S","choice_T","choice_U","choice_V","choice_W","choice_X","choice_Y","choice_Z"];
  777. let i=0;
  778. row.options.forEach(option =>{
  779. data[l[i]]=option;
  780. i=i+1;
  781. })
  782. obj.problems.push(data);
  783. });
  784. this.upladApi("http://121.37.103.75:10086/tiku/api/v1/problems",obj).then((resutData)=>{
  785. if(resutData.result==="success" && !!resutData.json){
  786. var data = JSON.parse(resutData.json).data;
  787. console.log(data);
  788. GM_setValue(id,1);
  789. }else{
  790. console.log(resutData);
  791. }
  792. });
  793. }
  794.  
  795.  
  796. MyPage.prototype.toLog=function(explain){
  797. //alert('啊绿: '+explain);
  798. this.initData();
  799. return this;
  800. }
  801. MyPage.prototype.findproblem = async function(text){
  802. let obj={
  803. "poolId": this.config.poolId,
  804. "token": "06e599f3-78db-4c71-b4fa-2b496beab1f6",
  805. "userId": this.config.tk_uid,
  806. "querry": {
  807. "operator": "contains",
  808. "argument1":"problemText",
  809. "argument2":text,
  810. }
  811. }
  812. /////
  813. await(this.upladApi("http://121.37.103.75:10086/tiku/api/v1/queryProblems",obj).then(async (resutData)=>{
  814. if(resutData.result==="success" && !!resutData.json){
  815. var data = JSON.parse(resutData.json).results;
  816. //处理数据,添加标识头
  817. let obj = {
  818. flag: "metoproblems",
  819. problems : data,
  820. }
  821. this.config.answer =this.resoluAnswers(obj);
  822. }
  823. }))
  824. }
  825.  
  826. MyPage.prototype.findproblems = async function(problems){
  827. let answer = []
  828. let obj={
  829. "poolId": this.config.poolId,
  830. "token": "06e599f3-78db-4c71-b4fa-2b496beab1f6",
  831. "userId": this.config.tk_uid,
  832. "querry": {
  833. "operator": "mulit",
  834. "argument1":"1",
  835. "argument2":"2",
  836. "problems":[]
  837. }
  838. }
  839. /////
  840. problems.forEach(problem =>{
  841. let problemobj = {
  842. "operator": "==",
  843. "argument1": "problemText",
  844. "argument2": problem,
  845. }
  846. obj.querry.problems.push(problemobj);
  847. })
  848. await(this.upladApi("http://121.37.103.75:10086/tiku/api/v1/queryProblems",obj).then(async (resutData)=>{
  849. if(resutData.result==="success" && !!resutData.json){
  850. var data = JSON.parse(resutData.json).results;
  851. //处理数据,添加标识头
  852. let obj = {
  853. flag: "metoproblems",
  854. problems : data,
  855. }
  856. answer = this.resoluAnswers(obj)
  857. // console.log(this.config.answers);
  858. }
  859. }))
  860. return answer
  861. }
  862. MyPage.prototype.start = async function(){ //搜题按钮实现
  863. const sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay))
  864. function random(min, max) {
  865. return Math.floor(Math.random() * (max - min)) + min;
  866. }
  867.  
  868. let config = this.config,$ = this.$;
  869. let HtmlUtil = this.HtmlUtil;
  870. let answers = await(this.getAnswers(config.id,true));
  871.  
  872. if(this.config.tk_uid == null || (answers == null)||JSON.stringify(answers) == '{}' || answers.rows.length <= 0){
  873. let subjects = []
  874. $('.topic-item').each(function(index,div){
  875. let Id = $(div).find('a').attr('name');
  876. let subject = $(div).find('.t-subject.t-item.moso-text.moso-editor').text();
  877. subject = HtmlUtil.htmlDecode(subject),
  878. subjects.push(subject);
  879. })
  880. answers = await(this.findproblems(subjects));
  881. }
  882. let aner = $('body').find("#aner")
  883. aner.css("display","block")
  884. console.log(answers)
  885. if(JSON.stringify(answers) == '{}' || !(answers.rows)){
  886. aner.text("没有搜索到答案,若提前阅卷时有答案,但此时没有请反馈")
  887. }else{
  888. aner.text("总共搜索到"+answers.rows.length+"题")
  889. }
  890.  
  891. $('.topic-item').each(function(index,div){
  892. let Id = $(div).find('a').attr('name');
  893. let flag_FT = false
  894. //console.log($(div).find('.t-subject.t-item.moso-text.moso-editor').html());
  895. let subject = $(div).find('.t-subject.t-item.moso-text.moso-editor').text();
  896. subject=HtmlUtil.htmlDecode(subject);
  897. // subject=escapeto(subject);
  898. //let space = new RegExp(`${String.fromCharCode(160)}`,"g"); /* no breaking space*/
  899. // console.log(subject);
  900. if( $(div).find('.show_answer').length == 0){
  901. $(div).find('.t-con').append("<div class='show_answer'></div>")
  902. }
  903. answers.rows.forEach(row=>{
  904. row.subject=HtmlUtil.htmlDecode(row.subject);
  905. if(row.subject == subject){
  906. $(div).find('.show_answer').text("答案:"+JSON.stringify(row.answers)).css('color','red'); // 添加答案在后方
  907. }
  908. });
  909. let $options = $(div).find('label');
  910. if($options.length == 0){
  911. $options = $(div).find('input');
  912. }
  913. $options.each(function(i,label){
  914. let content = $(label).find('.option-content.moso-text.moso-editor').text();//单多选题答案获取
  915. if(content == ""){
  916. content = $(label).find('.el-radio__label').text();//判断题答案获取
  917. flag_FT = true
  918. }
  919. answers.rows.forEach(row=>{
  920. if(row.subject == subject){
  921. if ($(label).find(".is-checked").length) {
  922. return;
  923. }
  924. if(content == ""){
  925. //填空题
  926. if(Array.isArray(row.answers[i])){
  927. $(label).val(row.answers[i][0]);
  928. }else{
  929. $(label).val(row.answers[i]);
  930. }
  931. ev = document.createEvent("HTMLEvents");
  932. ev.initEvent("input", true, true);
  933. $(label)[0].dispatchEvent(ev);
  934. }
  935. row.answers.forEach(async answer =>{
  936. if(flag_FT == true){
  937. if (answer == "T"){
  938. answer = "正确"
  939. }else if(answer == "F"){
  940. answer = "错误"
  941. }
  942. }
  943. try{
  944. if(content == answer){
  945. $(label).css('color','red');
  946. await sleep(random(500,1000))
  947. $(label).click()
  948. }
  949. }catch (e){
  950. console.log("发生异常:" + e);
  951. }
  952. });
  953. }
  954. });
  955.  
  956. });
  957. });
  958. // alert('阿绿: 操作完成,微信关注宁财小助手');
  959. window.my.config.timenum = answers.rows.length * 4
  960. $(".my-sticky-bottom").children("button:first").attr('id', 'submit')
  961. window.my.config.timer = setInterval(function() {
  962. window.my.config.timenum--
  963. if (window.my.config.timenum < 0) {
  964. $("#submit").text("交卷")
  965. $("#submit").attr("style", "")
  966. $("#submit").attr('disabled', false)
  967. clearInterval(window.my.config.timer)
  968. } else {
  969. $("#submit").attr('disabled', true)
  970. $("#x_start").attr('disabled', true)
  971. $("#submit").attr("style", "width:250px")
  972. $("#submit").text("请在" +window.my.config.timenum +"秒后交卷")
  973. }
  974. }, 1000)
  975.  
  976. let classListData = await (this.join_class());
  977. if(classListData.length > 0 ){
  978. classListData.forEach(cl =>{
  979. this.get_page(cl.id).then((result) =>{
  980. $(result).find(".interaction-row.interaction-row-open-enable").each(async function(index,div){
  981. let id = $(div).attr('data-id');
  982. let type = $(div).attr('data-type');
  983. let status = $(div).attr('data-row-status');
  984. if(type=="QUIZ"){
  985. if(!GM_getValue(id)){
  986. await(window.my.get_quiz_result(id,window.my.config.user_id,cl.id));
  987. }
  988. }
  989. })
  990. });
  991. })
  992. }
  993. //题库获取模块 end
  994. }
  995. _this.MyPage = MyPage;
  996. })(window);
  997.  
  998.  
  999. window.my = new window.MyPage({
  1000. id:"wzq",
  1001. width:80,
  1002. background:'#fff',
  1003. opacity:2,
  1004. pos:{
  1005. x:100,
  1006. y:100
  1007. }
  1008. }).toLog('私人圈子传播,请勿外传');

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址