Greasy Fork 支持简体中文。

支持支持【智慧树、中国大学mooc、慕课、国开、学习通、知到、国家开放大学、职教云、继续教育类】

【💚已完美兼容、智慧树、中国大学mooc、慕课、雨课堂、新国开、超星、学习通、知到、国家开放大学、蓝墨云、职教云、智慧职教、云班课精品课、山东专技、西财在线剩余网站仅支持部分功能💚】【半兼容、绎通云、U校园、学堂在线】、【💚完美应付测试,全自动答题,一键完成所有资源学习(视频挨个刷时不存在滴)、视频倍速💚】 、【💚新增AI搜题、AI问答,定制化服务💚】、【💚破除网站不可复制文字💚】、【💚基于生成式AI(ChatGPT)的答案生成💚】、【💚新增背题模式(遮挡答案,更好的进行考试复习)💚】、【特别感谢MeTo题库免费提供题目搜索功能】【💚作者在此保证,脚本无任何诸如(手机号,学校信息,等隐私信息)收集💚】

  1. // ==UserScript==
  2. // @name 支持支持【智慧树、中国大学mooc、慕课、国开、学习通、知到、国家开放大学、职教云、继续教育类】
  3. // @namespace qhyzsc
  4. // @version 4.0.1.3
  5. // @description 【💚已完美兼容、智慧树、中国大学mooc、慕课、雨课堂、新国开、超星、学习通、知到、国家开放大学、蓝墨云、职教云、智慧职教、云班课精品课、山东专技、西财在线剩余网站仅支持部分功能💚】【半兼容、绎通云、U校园、学堂在线】、【💚完美应付测试,全自动答题,一键完成所有资源学习(视频挨个刷时不存在滴)、视频倍速💚】 、【💚新增AI搜题、AI问答,定制化服务💚】、【💚破除网站不可复制文字💚】、【💚基于生成式AI(ChatGPT)的答案生成💚】、【💚新增背题模式(遮挡答案,更好的进行考试复习)💚】、【特别感谢MeTo题库免费提供题目搜索功能】【💚作者在此保证,脚本无任何诸如(手机号,学校信息,等隐私信息)收集💚】
  6. // @author qhyzsc
  7. // @match *://*.zhihuishu.com/*
  8. // @connect api.902000.xyz
  9. // @connect report.902000.xyz
  10. // @connect mooc1.chaoxing.com
  11. // @connect mooc1-1.chaoxing.com
  12. // @connect mooc1-2.chaoxing.com
  13. // @connect mooc2-ans.chaoxing.com
  14. // @connect mooc1-api.chaoxing.com
  15. // @connect stat2-ans.chaoxing.com
  16. // @connect passport2.chaoxing.com
  17. // @connect zhibo.chaoxing.com
  18. //----------------------------------------
  19. // @connect mooc1.hnust.edu.cn
  20. // @connect stat2-ans.hnust.edu.cn
  21. // @connect passport2.hnust.edu.cn
  22. // @connect zhibo.hnust.edu.cn
  23. //----------------------------------------
  24. // @connect mooc1.hnsyu.net
  25. // @connect stat2-ans.hnsyu.net
  26. // @connect passport2.hnsyu.net
  27. // @connect zhibo.hnsyu.net
  28. //----------------------------------------
  29. // @connect mooc1.gdhkmooc.com
  30. // @connect stat2-ans.gdhkmooc.com
  31. // @connect passport2.gdhkmooc.com
  32. // @connect zhibo.gdhkmooc.com
  33. //----------------------------------------
  34. // @connect mooc1.zut.edu.cn
  35. // @connect stat2-ans.zut.edu.cn
  36. // @connect passport2.zut.edu.cn
  37. // @connect zhibo.zut.edu.cn
  38. //----------------------------------------
  39. // @connect mooc1.wljx.hfut.edu.cn
  40. // @connect stat2-ans.wljx.hfut.edu.cn
  41. // @connect passport2.wljx.hfut.edu.cn
  42. // @connect zhibo.wljx.hfut.edu.cn
  43. //----------------------------------------
  44. // @connect mooc1.hncj.edu.cn
  45. // @connect stat2-ans.hncj.edu.cn
  46. // @connect passport2.hncj.edu.cn
  47. // @connect zhibo.hncj.edu.cn
  48. //----------------------------------------
  49. // @connect mooc1.qutjxjy.cn
  50. // @connect stat2-ans.qutjxjy.cn
  51. // @connect passport2.qutjxjy.cn
  52. // @connect zhibo.qutjxjy.cn
  53. //----------------------------------------
  54. // @connect mooc1.jxjyzx.xust.edu.cn
  55. // @connect stat2-ans.jxjyzx.xust.edu.cn
  56. // @connect passport2.jxjyzx.xust.edu.cn
  57. // @connect zhibo.jxjyzx.xust.edu.cn
  58. //----------------------------------------
  59. // @connect mooc1.xueyinonline.com
  60. // @connect stat2-ans.xueyinonline.com
  61. // @connect passport2.xueyinonline.com
  62. // @connect zhibo.xueyinonline.com
  63. //----------------------------------------
  64. // @connect mooc1.cqrspx.cn
  65. // @connect stat2-ans.cqrspx.cn
  66. // @connect passport2.cqrspx.cn
  67. // @connect zhibo.cqrspx.cn
  68. //----------------------------------------
  69. // @connect mooc1.ynny.cn
  70. // @connect stat2-ans.ynny.cn
  71. // @connect passport2.ynny.cn
  72. // @connect zhibo.ynny.cn
  73. //----------------------------------------
  74. // @connect mooc1.cugbonline.cn
  75. // @connect stat2-ans.cugbonline.cn
  76. // @connect passport2.cugbonline.cn
  77. // @connect zhibo.cugbonline.cn
  78. //----------------------------------------
  79. // @connect mooc1.xust.edu.cn
  80. // @connect stat2-ans.xust.edu.cn
  81. // @connect passport2.xust.edu.cn
  82. // @connect zhibo.xust.edu.cn
  83. //----------------------------------------
  84. // @connect mooc1.xynu.edu.cn
  85. // @connect stat2-ans.xynu.edu.cn
  86. // @connect passport2.xynu.edu.cn
  87. // @connect zhibo.xynu.edu.cn
  88. //----------------------------------------
  89. // @connect mooc1.hnvist.cn
  90. // @connect stat2-ans.hnvist.cn
  91. // @connect passport2.hnvist.cn
  92. // @connect zhibo.hnvist.cn
  93. // @run-at document-end
  94. // @grant unsafeWindow
  95. // @grant GM_xmlhttpRequest
  96. // @grant GM_setClipboard
  97. // @license MIT
  98. // @original-script https://greasyfork.org/en/scripts/380506
  99. // @original-author wyn665817
  100. // @original-license MIT
  101. // ==/UserScript==
  102. // 设置修改后,需要刷新或重新打开网课页面才会生效
  103. var setting = {
  104. // 8E3 == 8000,科学记数法,表示毫秒数
  105. time: 8E3 // 默认响应速度为8秒,不建议小于5秒,减轻服务器响应压力
  106. // 1代表开启,0代表关闭
  107. ,video: 1 // 视频支持课程、见面课,默认开启
  108. ,work: 1 // 自动答题功能,支持章测试、考试,高准确率,默认开启
  109. ,jump: 1 // 自动切换视频,支持课程、见面课,默认开启
  110. // 仅开启video时,修改此处才会生效
  111. ,line: '流畅' // 视频播放的默认线路,可选参数:['高清', '流畅', '校内'],默认'流畅'
  112. ,vol: '0' // 默认音量的百分数,设定范围:[0,100],'0'为静音,默认'0'
  113. ,speed: '1.5' // 进度统计速率,高倍率可以快速完成任务点,设定范围:(0,+∞),默认'1.5'倍
  114. // 上方参数支持在页面改动,下方参数仅支持代码处修改
  115. ,que: 1 // 屏蔽视频时间点对应的节试题,取消屏蔽则自动切换为模拟点击关闭弹题,默认开启
  116. ,danmu: 0 // 见面课弹幕,关闭后在网页中无法手动开启,默认关闭
  117. ,habit: '0' // 限制视频挂机时长,单位是分钟,如需挂机习惯分,可以修改参数为'30',默认不限制
  118. // 仅开启work时,修改此处才会生效
  119. ,none: 0 // 无匹配答案时执行默认操作,默认关闭
  120. ,hide: 0 // 不加载答案搜索提示框,键盘↑和↓可以临时移除和加载,默认关闭
  121. },
  122. _self = unsafeWindow,
  123. url = location.pathname,
  124. $ = _self.jQuery,
  125. xhr = _self.XMLHttpRequest;
  126. String.prototype.toCDB = function () {
  127. return this.replace(/\s/g, '').replace(/[\uff01-\uff5e]/g, function (str) {
  128. return String.fromCharCode(str.charCodeAt(0) - 65248);
  129. }).replace(/[“”]/g, '"').replace(/[‘’]/g, "'").replace(/。/g, '.');
  130. };
  131. // setting.time += Math.ceil(setting.time * Math.random()) - setting.time / 2;
  132. setting.queue = setting.curs = [];
  133. if (!$) {}
  134. else if (url.match('/videoList')) {
  135. $.tmDialog.alert({
  136. content: '2.X版本已取消支持旧版界面',
  137. title: '智慧树网课助手提示'
  138. });
  139. }
  140. else if (url == '/videoStudy.html') {
  141. setting.habit *= 6E4;
  142. setting.video && hookVideo(_self.vjsComponent, 1);
  143. setting.jump && setInterval(checkToNext, setting.time);
  144. }
  145. else if (url == '/portals_h5/2clearning.html') {
  146. setting.video && hookVideo(_self.vjsComponent, 2);
  147. setting.jump && setInterval(checkToNext, setting.time);
  148. }
  149. else if (url == '/live/vod_room.html') {
  150. setting.video && hookVideo(_self.vjsComponent);
  151. setting.jump && setInterval(checkToNext, setting.time, 1);
  152. }
  153. else if (location.hostname.match('examh5')) {
  154. setTimeout(relieveLimit, 100, document);
  155. if (location.hash.match(/dohomework|doexamination/) && setting.work) beforeFind();
  156. $(window).on('hashchange', function () {
  157. setting.work && location.reload();
  158. });
  159. }
  160. else if (url.match('/sourceLearning')) {
  161. var $tip = $('.source-file-item');
  162. setting.jump && setInterval(function () {
  163. if (!$('.settleOn .finish').length) return;
  164. $tip.slice($tip.index($('.settleOn')) + 1).not(':has(.finish)').eq(0).find('.file-name').click();
  165. }, setting.time);
  166. }
  167. else if (url == '/shareCourse/questionDetailPage') {
  168. setTimeout(relieveLimit, 100, document);
  169. $('textarea[oncut]').each(function () {
  170. setTimeout(relieveLimit, 100, this);
  171. });
  172. }
  173. function hookVideo(Hooks, tip) {
  174. // _self.PlayerUtil.debugMode = true;
  175. _self.vjsComponent = function() {
  176. var config = arguments[0],
  177. options = config.options,
  178. line = $.map(options.sourceSrc.lines, function(value) {
  179. return value.lineName.replace('标准', '高清');
  180. }),
  181. vol = setting.vol > 100 ? 100 : setting.vol,
  182. rate = tip == 3 ? [1, 1.25, 1.5, 2, 2.5, 3] : [1, 1.25, 1.5];
  183. vol = Math.round(vol) / 100;
  184. options.volume = vol > 0 ? vol : 0;
  185. options.autostart = true;
  186. setting.speed = setting.speed > 0 ? +setting.speed : 1;
  187. options.rate = $.inArray(setting.speed, rate) < 0 ? options.rate : setting.speed;
  188. tip && config.callback.playbackRate(setting.speed);
  189. options.chooseLine = $.inArray(setting.line, line) + 1 || options.chooseLine + 1;
  190. options.src = options.sourceSrc.lines[--options.chooseLine].lineUrl || options.src;
  191. if (!setting.danmu) {
  192. config.defOptions.control.danmuBtn = false;
  193. delete options.control.danmuBtn;
  194. }
  195. Hooks.apply(this, arguments);
  196. config.player.on('loadstart', function() {
  197. this.loop(true);
  198. this.play();
  199. $('.speedBox span').text('X ' + setting.speed);
  200. });
  201. };
  202. $(document).on('click', '.definiLines b', function() {
  203. setting.line = ({xiaonei: '校内', line1gq: '高清', line1bq: '流畅'})[this.classList[0]];
  204. }).on('mouseup click', function() {
  205. setting.vol = _self.PlayerStarter.playerArray[0].player.cache_.volume * 100;
  206. }).on('click', '.speedList div', function() {
  207. setting.speed = $(this).attr('rate');
  208. });
  209. if (tip != 1) return;
  210. setting.tip = setting.habit && setInterval(totalTime, setting.time);
  211. setInterval(doTest, 1E3);
  212. _self.XMLHttpRequest = setting.que ? function() {
  213. var ajax = new xhr(),
  214. open = ajax.open;
  215. ajax.open = function(method, url) {
  216. if (url.match('/loadVideoPointerInfo')) method = 'OPTIONS';
  217. return open.apply(this, arguments);
  218. };
  219. return ajax;
  220. } : xhr;
  221. }
  222. function totalTime() {
  223. var player = _self.PlayerStarter.playerArray[0].player;
  224. setting.habit -= player.paused() ? 0 : setting.time;
  225. if (setting.habit > 0) return;
  226. clearInterval(setting.tip);
  227. player.pause();
  228. $.getScript('//cdn.jsdelivr.net/gh/sentsin/layer/dist/layer.js', function () {
  229. _self.layer.open({
  230. content: '已达到挂机限制时间',
  231. title: '智慧树网课助手提示'
  232. });
  233. });
  234. }
  235. function checkToNext(tip) {
  236. var $tip = $('.video, .lessonItem');
  237. if ($('.current_play .time_icofinish').length) {
  238. $tip.slice($tip.index($('.current_play')) + 1).not(':has(.time_icofinish)').eq(0).click();
  239. }
  240. else if ($('.lessonItemActive .finish').length) {
  241. // _self.PlayerStarter.playerArray[0].callback.playerNext();
  242. $tip.slice($tip.index($('.lessonItemActive')) + 1).not(':has(.finish)').eq(0).click();
  243. }
  244. else if (tip) {
  245. $('.current_player:contains("100%") + li').click();
  246. // $('.finish_tishi').hasClass('disNo') || console.log('签到已完成');
  247. }
  248. }
  249. function doTest() {
  250. if (!$('.dialog-test').length) {}
  251. else if (setting.queue.length) {
  252. $(setting.queue.shift()).parent().click();
  253. }
  254. else if (!$('.answer').length) {
  255. $('.topic-item').eq(0).click();
  256. }
  257. else if ($('.right').length) {
  258. $('.dialog-test .btn').click();
  259. _self.PlayerStarter.playerArray[0].player.play();
  260. }
  261. else {
  262. var tip = $('.answer span').text().match(/[A-Z]/g) || [];
  263. if (tip.length == 1) return $('.topic-option-item:contains(' + tip[0] + ')').click();
  264. $('.topic-option-item').each(function () {
  265. $.inArray($(this).text().slice(0, 1), tip) < 0 == $(this).hasClass('active') && setting.queue.push(this);
  266. });
  267. }
  268. }
  269. function relieveLimit(doc) {
  270. if (!doc.oncut && !doc.onselectstart) return setTimeout(relieveLimit, 100, doc);
  271. doc.oncontextmenu = doc.onpaste = doc.oncopy = doc.oncut = doc.onselectstart = null;
  272. }
  273. function beforeFind() {
  274. _self.XMLHttpRequest = function () {
  275. var ajax = new xhr();
  276. ajax.onload = function (e) {
  277. if (this.status != 200 || !this.responseURL.match(/doHomework|doExam/)) return;
  278. var obj = JSON.parse(this.responseText);
  279. collectData(obj.rt.examBase);
  280. };
  281. return ajax;
  282. };
  283. setting.div = $(
  284. '<div style="border: 2px dashed rgba(181,216,251,0.7); width: 330px; position: fixed; top: 0; left: 0; z-index: 99999; background-color: rgba(181,216,251,0.6); overflow-x: auto;">' +
  285. '<span style="font-size: medium;"></span>' +
  286. '<div style="font-size: medium;">正在搜索答案...</div>' +
  287. '<button style="margin-right: 10px;">暂停答题</button>' +
  288. '<button style="margin-right: 10px;">重新查询</button>' +
  289. '<button style="margin-right: 10px;">折叠面板</button>' +
  290. '<button style="display: none;">未作答题目</button>' +
  291. '<form style="margin: 2px 0;">' +
  292. '<label style="font-weight: bold; color: red;">自定义答题范围:</label>' +
  293. '<input name="num" type="number" min="1" placeholder="开始" style="width: 60px;" disabled>' +
  294. '<span> ~ </span>' +
  295. '<input name="max" type="number" min="1" placeholder="结束" style="width: 60px;" disabled>' +
  296. '</form>' +
  297. '<div style="max-height: 300px; overflow-y: auto;">' +
  298. '<table border="1" style="font-size: 12px;">' +
  299. '<thead>' +
  300. '<tr>' +
  301. '<th style="width: 30px; min-width: 30px; font-weight: bold; text-align: center;">题号</th>' +
  302. '<th style="width: 60%; min-width: 130px; font-weight: bold; text-align: center;">题目(点击可复制)</th>' +
  303. '<th style="min-width: 130px; font-weight: bold; text-align: center;">答案(点击可复制)</th>' +
  304. '</tr>' +
  305. '</thead>' +
  306. '<tfoot style="display: none;">' +
  307. '<tr>' +
  308. '<th colspan="3" style="font-weight: bold; text-align: center;">答案提示框 已折叠</th>' +
  309. '</tr>' +
  310. '</tfoot>' +
  311. '<tbody>' +
  312. '<tr>' +
  313. '<td colspan="3" style="display: none;"></td>' +
  314. '</tr>' +
  315. '</tbody>' +
  316. '</table>' +
  317. '</div>' +
  318. '</div>'
  319. ).appendTo('body').on('click', 'button, td', function () {
  320. var len = $(this).prevAll('button').length;
  321. if (this.nodeName == 'TD') {
  322. $(this).prev().length && GM_setClipboard($(this).text());
  323. }
  324. else if (len === 0) {
  325. if (setting.loop) {
  326. clearInterval(setting.loop);
  327. delete setting.loop;
  328. len = [false, '已暂停搜索', '继续答题'];
  329. }
  330. else {
  331. setting.loop = setInterval(findAnswer, setting.time);
  332. len = [true, '正在搜索答案...', '暂停答题'];
  333. }
  334. setting.div.find('input').attr('disabled', len[0]);
  335. setting.div.children('div:eq(0)').html(function () {
  336. return $(this).data('html') || len[1];
  337. }).removeData('html');
  338. $(this).html(len[2]);
  339. }
  340. else if (len == 1) {
  341. location.reload();
  342. }
  343. else if (len == 2) {
  344. setting.div.find('tbody, tfoot').toggle();
  345. }
  346. else if (len == 3) {
  347. var $li = $('.el-scrollbar__wrap li'),
  348. $tip = $li.filter('.white, .yellow').eq(0);
  349. $tip.click().length ? setting.div.children('div:last').scrollTop(function () {
  350. var $tr = $('tbody tr', this).has('td:nth-child(1):contains(' + $tip.text() + ')');
  351. if (!$tr.length) return arguments[1];
  352. return $tr.offset().top - $tr.parents('table').offset().top; // $tr[0].offsetTop
  353. }) : $(this).hide();
  354. }
  355. }).on('change', 'input', function () {
  356. setting[this.name] = this.value.match(/^\d+$/) ? parseInt(this.value) - 1 : -1;
  357. if (!this.value) setting[this.name] = this.name == 'num' ? 0 : undefined;
  358. }).detach(setting.hide ? '*' : 'html');
  359. setting.type = {
  360. 单选题: 1,
  361. 多选题: 2,
  362. 填空题: 3,
  363. 问答题: 4,
  364. '分析题/解答题/计算题/证明题': 5,
  365. '阅读理解(选择)/完型填空': 9,
  366. 判断题: 14
  367. };
  368. setting.lose = setting.num = setting.small = 0;
  369. $(document).keydown(function (event) {
  370. if (event.keyCode == 38) {
  371. setting.div.detach();
  372. }
  373. else if (event.keyCode == 40) {
  374. setting.div.appendTo('body');
  375. }
  376. });
  377. setting.loop = setInterval(findAnswer, setting.time, true);
  378. setInterval(function () {
  379. $(setting.queue.shift()).parent().click();
  380. }, 1E3);
  381. }
  382. function findAnswer(tip) {
  383. if (setting.queue.length) {
  384. return;
  385. }
  386. else if (tip && !$('.answerCard').length) {
  387. return setting.div.children('div:eq(0)').data('html', '非自动答题页面').siblings('button:eq(0)').click();
  388. }
  389. else if (setting.max < 0 || setting.num < 0) {
  390. return setting.div.children('div:eq(0)').data('html', '范围参数应为 <font color="red">正整数</font>').siblings('button:eq(0)').click();
  391. }
  392. else if (setting.num >= $('.subject_stem').length || setting.num > setting.max) {
  393. // setting.div.children('button:eq(3)').toggle(!!setting.lose);
  394. tip = setting.lose ? '共有 <font color="red">' + setting.lose + '</font> 道题目待完善(已深色标注)' : '答题已完成';
  395. return setting.div.children('div:eq(0)').data('html', tip).siblings('button:eq(0), form').hide().click();
  396. }
  397. else if (!setting.curs.length) {
  398. setting.curs = $('.infoList span').map(function () {
  399. return $(this).text().trim();
  400. });
  401. if (!setting.curs.length) return;
  402. }
  403. var $TiMu = $('.subject_stem').eq(setting.num).parent(),
  404. $dom = $TiMu.find('.smallStem_describe').eq(setting.small).children('div').slice(1, -1),
  405. question = filterStyle($dom) || filterStyle($TiMu.find('.subject_describe')),
  406. type = $TiMu.find('.subject_type').text().match(/【(.+)】|$/)[1];
  407. type = type ? setting.type[type] || 0 : -1;
  408. GM_xmlhttpRequest({
  409. method: 'POST',
  410. url: 'http://api.902000.xyz:88/wkapi.php',
  411. headers: {
  412. 'Content-type': 'application/x-www-form-urlencoded'
  413. },
  414. data: 'course=' + encodeURIComponent(setting.curs[0]) + '&chapter=' + encodeURIComponent(setting.curs[1]) + '&q=' + encodeURIComponent(question) + '&type=' + type,
  415. timeout: setting.time,
  416. onload: function (xhr) {
  417. if (!setting.loop) {}
  418. else if (xhr.status == 200) {
  419. var obj = $.parseJSON(xhr.responseText) || {};
  420. if (obj.answer) {
  421. setting.div.children('div:eq(0)').text('正在搜索答案...');
  422. var data = obj.answer.replace(/&/g, '&amp;').replace(/<([^i])/g, '&lt;$1');
  423. obj.answer = /^http/.test(data) ? '<img src="' + obj.answer + '">' : obj.answer;
  424. $(
  425. '<tr>' +
  426. '<td style="text-align: center;">' + $TiMu.find('.subject_num').text().trim().replace('.', '') + '</td>' +
  427. '<td title="点击可复制">' + (question.match('<img') ? question : question.replace(/&/g, '&amp;').replace(/</g, '&lt')) + '</td>' +
  428. '<td title="点击可复制">' + (/^http/.test(data) ? obj.answer : '') + data + '</td>' +
  429. '</tr>'
  430. ).appendTo(setting.div.find('tbody')).css('background-color', function () {
  431. $dom = $dom.length ? $dom.closest('.examPaper_subject') : $TiMu;
  432. if (fillAnswer($dom, obj, type)) return '';
  433. setting.div.children('button:eq(3)').show();
  434. return 'rgba(0,134,139, 0.6)';
  435. });
  436. setting.small = ++setting.small < $TiMu.find('.smallStem_describe').length ? setting.small : (setting.num++, 0);
  437. }
  438. else {
  439. setting.div.children('div:eq(0)').html(obj.data || '服务器繁忙,正在重试...');
  440. }
  441. setting.div.children('span').html(obj.msg || '');
  442. }
  443. else if (xhr.status == 403) {
  444. setting.div.children('div:eq(0)').data('html', '请求过于频繁,建议稍后再试').siblings('button:eq(0)').click();
  445. }
  446. else {
  447. setting.div.children('div:eq(0)').text('服务器异常,正在重试...');
  448. }
  449. },
  450. ontimeout: function () {
  451. setting.loop && setting.div.children('div:eq(0)').text('服务器超时,正在重试...');
  452. }
  453. });
  454. }
  455. function fillAnswer($TiMu, obj, type) {
  456. var $div = $TiMu.find('.nodeLab'),
  457. str = String(obj.answer).toCDB() || new Date().toString(),
  458. data = str.split(/#|\x01|\|/),
  459. state = setting.lose;
  460. // $div.find(':radio:checked').prop('checked', false);
  461. obj.code > 0 && $div.each(function () {
  462. var $input = $('input', this)[0],
  463. tip = filterStyle('.node_detail', this).toCDB() || new Date().toString();
  464. if (tip.match(/^(正确|是|对|√|T|ri)$/)) {
  465. data.join().match(/(^|,)(正确|是|对|√|T|ri)(,|$)/) && setting.queue.push($input);
  466. }
  467. else if (tip.match(/^(错误|否|错|×|F|wr)$/)) {
  468. data.join().match(/(^|,)(错误|否|错|×|F|wr)(,|$)/) && setting.queue.push($input);
  469. }
  470. else if (type == 2) {
  471. Boolean($.inArray(tip, data) + 1 || str.indexOf(tip) + 1) == $input.checked || setting.queue.push($input);
  472. }
  473. else {
  474. $.inArray(tip, data) + 1 && setting.queue.push($input);
  475. }
  476. });
  477. if (setting.queue.length) {}
  478. else if (/^(1|2|14)$/.test(type)) {
  479. var $input = $div.find('input');
  480. $input.is(':checked') || (setting.none ? setting.queue.push($input[Math.floor(Math.random() * $input.length)]) : setting.lose++);
  481. }
  482. else if (/^[3-5]$/.test(type)) {
  483. var $text = $TiMu.find('textarea');
  484. data = String(obj.data).split(/#|\x01|\|/);
  485. (obj.code > 0 && data.length == $text.length) || setting.none || setting.lose++;
  486. state == setting.lose && $text.each(function (index) {
  487. this.value = (obj.code > 0 && (data[index] || '').trim()) || '不会';
  488. // if (this.value == this._value) return true;
  489. this.dispatchEvent(new Event('input'));
  490. this.dispatchEvent(new Event('blur'));
  491. });
  492. }
  493. else {
  494. setting.none || setting.lose++;
  495. }
  496. return state == setting.lose;
  497. }
  498. function collectData(obj, data) {
  499. setting.data = data = {};
  500. data.id = obj.id;
  501. data.name = obj.name;
  502. data.course = obj.courseName;
  503. data.chapter = obj.toChapter || obj.explain;
  504. data.timu = [];
  505. $.each(obj.workExamParts, function () {
  506. $.each(this.questionDtos, function () {
  507. if (this.questionOptions) return pushData(this, data.timu);
  508. $.each(this.questionChildrens, function () {
  509. pushData(this, data.timu);
  510. });
  511. });
  512. });
  513. GM_xmlhttpRequest({
  514. method: 'POST',
  515. url: 'http://report.902000.xyz:88/report/zhs',
  516. headers: {
  517. 'Content-type': 'application/x-www-form-urlencoded'
  518. },
  519. data: 'data=' + encodeURIComponent(JSON.stringify(data))
  520. });
  521. }
  522. function pushData(obj, arr) {
  523. arr.push({
  524. id: obj.id,
  525. question: filterStyle('<p>' + obj.name + '</p>'),
  526. option: $.map(obj.questionOptions, function (val) {
  527. return filterStyle('<p>' + val.content + '</p>');
  528. }),
  529. key: $.map(obj.questionOptions, function (val) {
  530. return val.id;
  531. }).join(),
  532. type: obj.questionType.id
  533. });
  534. }
  535. var $dom = $(dom, that).clone().find('style').remove().end();
  536. return $dom.find('img[src]').replaceWith(function () {
  537. return $('<p></p>').text('<img src="' + $(this).attr('src') + '">');
  538. }).end().text().trim();