超星学习通助理[章节、作业、考试、视频] 支持新版|修复倍速|优化课程切换|支持图片题

超星全自动刷课,支持章节、作业、考试、视频等多项任务点。

  1. // ==UserScript==
  2. // @name 超星学习通助理[章节、作业、考试、视频] 支持新版|修复倍速|优化课程切换|支持图片题
  3. // @version 3.6
  4. // @namespace http://tampermonkey.net/
  5. // @description 超星全自动刷课,支持章节、作业、考试、视频等多项任务点。
  6. // @author JunXiaoRuo
  7. // @match *://*.chaoxing.com/*
  8. // @match *://*.edu.cn/*
  9. // @match *://*.nbdlib.cn/*
  10. // @match *://*.hnsyu.net/*
  11. // @connect s.jiaoyu139.com
  12. // @connect study.jszkk.com
  13. // @original-script https://gf.qytechs.cn/zh-CN/scripts/437514-%E8%B6%85%E6%98%9F%E5%AD%A6%E4%B9%A0%E9%80%9A%E5%8A%A9%E7%90%86-%E7%AB%A0%E8%8A%82-%E4%BD%9C%E4%B8%9A-%E8%80%83%E8%AF%95-%E8%A7%86%E9%A2%91-%E6%94%AF%E6%8C%81%E6%96%B0%E7%89%88-%E4%BF%AE%E5%A4%8D%E5%80%8D%E9%80%9F-%E4%BC%98%E5%8C%96%E8%AF%BE%E7%A8%8B%E5%88%87%E6%8D%A2-%E6%94%AF%E6%8C%81%E5%9B%BE%E7%89%87%E9%A2%98
  14. // @run-at document-end
  15. // @grant unsafeWindow
  16. // @grant GM_xmlhttpRequest
  17. // @grant GM_setValue
  18. // @grant GM_getValue
  19. // @grant GM_info
  20. // @grant GM_setClipboard
  21. // @license MIT
  22. // ==/UserScript==
  23.  
  24. // 设置修改后,需要刷新或重新打开网课页面才会生效
  25. var setting = {
  26. // 2E3 == 2000,科学记数法,表示毫秒数
  27. time: 4E3 // 默认响应速度为5秒,不建议小于2秒
  28. , review: 0 // 复习模式,完整挂机视频(音频)时长,支持挂机任务点已完成的视频和音频,默认关闭
  29. , queue: 1 // 队列模式,开启后任务点逐一完成,关闭则单页面所有任务点同时进行,默认开启
  30. // 1代表开启,0代表关闭
  31. , video: 1 // 视频支持后台、切换窗口不暂停,支持多视频,默认开启
  32. , work: 1 // 自动答题功能(章节测验),作业需要手动开启查询,高准确率,默认开启
  33. , audio: 1 // 音频自动播放,与视频功能共享vol和rate参数,默认开启
  34. , book: 1 // 图书阅读任务点,非课程阅读任务点,默认开启
  35. , docs: 1 // 文档阅读任务点,PPT类任务点自动完成阅读任务,默认开启
  36. // 本区域参数,上方为任务点功能,下方为独立功能
  37. , jump: 1 // 自动切换任务点、章节、课程(需要配置course参数),默认开启
  38. , read: '65' // 挂机课程阅读时间,单位是分钟,'65'代表挂机65分钟,请手动打开阅读页面,默认'65'分钟
  39. , face: 1 // 解除面部识别(不支持二维码类面部采集),此功能仅为临时解除,默认开启
  40. , total: 1 // 显示课程进度的统计数据,在学习进度页面的上方展示,默认开启
  41. // 仅开启video(audio)时,修改此处才会生效
  42. , line: '公网1' // 视频播放的默认资源线路,此功能适用于系统默认线路无资源,默认'公网1'
  43. , http: '标清' // 视频播放的默认清晰度,无效参数则使用系统默认清晰度,默认'标清'
  44. // 本区域参数,上方为video功能独享,下方为audio功能共享
  45. , vol: '0' // 默认音量的百分数,设定范围:[0,100],'0'为静音,默认'0'
  46. , rate: '1' // 视频播放默认倍率,参数范围0∪[0.0625,16],'0'为秒过,默认'1'倍
  47. // 仅开启work时,修改此处才会生效
  48. , auto1: 1 // 答题完成后自动提交,默认开启
  49. , none: 0 // 无匹配答案时执行默认操作,关闭后若题目无匹配答案则会暂时保存已作答的题目,默认开启
  50. , scale: 0 // 富文本编辑器高度自动拉伸,用于文本类题目,答题框根据内容自动调整大小,默认关闭
  51. // 仅开启jump时,修改此处才会生效
  52. , course: 1 // 当前课程完成后自动切换课程,仅支持按照根目录课程顺序切换,默认开启
  53. , lock: 1 // 跳过未开放(图标是锁)的章节,即闯关模式或定时发放的任务点,默认开启
  54. },
  55. _self = unsafeWindow,
  56. url = location.pathname,
  57. top = _self,
  58. script_info=GM_info.script;
  59.  
  60. jq_layer();
  61. if(GM_getValue("jump")!=undefined){
  62. setting.jump=GM_getValue("jump");
  63. }
  64. if(GM_getValue("auto")!=undefined){
  65. setting.auto1=GM_getValue("auto");
  66. }
  67. if(GM_getValue("none")!=undefined){
  68. setting.none=GM_getValue("none");
  69. }
  70. if(GM_getValue("queue")!=undefined){
  71. setting.queue=GM_getValue("queue");
  72. }
  73. if(GM_getValue("course")!=undefined){
  74. setting.course=GM_getValue("course");
  75. }
  76. if(GM_getValue("rate")!=undefined){
  77. setting.rate=GM_getValue("rate");
  78. }
  79. var pz={
  80. };
  81. var tmpSubmit = 1;//本次
  82. Object.defineProperty(setting, "auto", {
  83. get: function () {
  84. if (tmpSubmit >= 2) {
  85. return tmpSubmit === 3;
  86. }
  87. return GM_getValue("autosubmit");
  88. }, set: function (value) {
  89. tmpSubmit = value + 2;
  90. }
  91. });
  92. setting.notice = '公告栏';
  93. if (url != '/studyApp/studying' && top != _self.top) document.domain = location.host.replace(/.+?\./, '');
  94. try {
  95. while (top != _self.top) {
  96. top = top.parent.document ? top.parent : _self.top;
  97. if (top.location.pathname == '/mycourse/studentstudy') break;
  98. }
  99. } catch (err) {
  100. // console.log(err);
  101. top = _self;
  102. }
  103. var $ = _self.jQuery || top.jQuery,
  104. parent = _self == top ? self : _self.parent,
  105. Ext = _self.Ext || parent.Ext || {},
  106. UE = _self.UE,
  107. vjs = _self.videojs;
  108. $('body').mousedown(function(e){
  109. if(3 == e.which){
  110. setting_s();
  111. }
  112. })
  113. if (url != '/module/audioplay.html'){
  114. try {
  115. pz.layui= _self.layui || top.layui;
  116. pz.layui.use('layer', function () {
  117. pz.layer=this.layer;
  118. pz.layer.closeAll();
  119.  
  120.  
  121. });
  122.  
  123. } catch (err) {
  124.  
  125. }
  126. }
  127.  
  128. $('head').append('<link href="https://lib.baomitu.com/layui/2.6.8/css/layui.css" rel="stylesheet" type="text/css" />');
  129. $('.Header').find('a:contains(回到旧版)')[0]?$('.Header').find('a:contains(回到旧版)')[0].click():'';
  130. String.prototype.toCDB = function () {
  131. return this.replace(/\s/g, '').replace(/[\uff01-\uff5e]/g, function (str) {
  132. return String.fromCharCode(str.charCodeAt(0) - 65248);
  133. }).replace(/[“”]/g, '"').replace(/[‘’]/g, "'").replace(/。/g, '.');
  134. };
  135. setting.normal = ''; // ':visible'
  136. // setting.time += Math.ceil(setting.time * Math.random()) - setting.time / 2;
  137. setting.job = [':not(*)'];
  138.  
  139. setting.video && setting.job.push('iframe[src*="/video/index.html"]');
  140. setting.work && setting.job.push('iframe[src*="/work/index.html"]');
  141. setting.audio && setting.job.push('iframe[src*="/audio/index.html"]');
  142. setting.book && setting.job.push('iframe[src*="/innerbook/index.html"]');
  143. setting.docs && setting.job.push('iframe[src*="/ppt/index.html"]', 'iframe[src*="/pdf/index.html"]');
  144. setting.tip = !setting.queue || top != _self && jobSort($ || Ext.query);
  145. console.log(url);
  146. if (url == '/mycourse/studentstudy') {
  147.  
  148. _self.checkMobileBrowerLearn = $.noop;
  149. var classId = location.search.match(/cla[zs]{2}id=(\d+)/i)[1] || 0,
  150. courseId = _self.courseId || location.search.match(/courseId=(\d+)/i)[1] || 0;
  151. setting.lock || $('#coursetree').on('click', '[onclick*=void], [href*=void]', function () {
  152. _self.getTeacherAjax(courseId, classId, $(this).parent().attr('id').slice(3));
  153. });
  154. } else if (url == '/ananas/modules/video/index.html' && setting.video) {
  155.  
  156. if (setting.review) _self.greenligth = Ext.emptyFn;
  157. checkPlayer(_self.supportH5Video());
  158.  
  159. } else if (url == '/work/doHomeWorkNew' || url == '/api/work' || url == '/work/addStudentWorkNewWeb'|| url == '/mooc2/work/dowork') {
  160. setting.knowledgeId=0
  161. try {
  162. setting.knowledgeId= location.search.match(/knowledgeid=(\d+)/i)[1];
  163. } catch (err) {}
  164. if (setting.knowledgeId==0&&typeof unsafeWindow.layui == 'undefined') {
  165. var Head = document.getElementsByTagName('head')[0] || document.documentElement;
  166. var JQ = document.createElement('script');
  167. JQ.src = 'https://lib.baomitu.com/layui/2.6.8/layui.js';
  168. JQ.type = 'text/javascript';
  169. JQ.async = true;
  170. Head.insertBefore(JQ, Head.firstChild);
  171. GM_wait();
  172. }else{
  173. work_start();
  174. }
  175. function GM_wait() {
  176. if (typeof unsafeWindow.layui == 'undefined') {
  177. console.log("正在加载");
  178. window.setTimeout(GM_wait, 100);
  179. } else {
  180. work_start()
  181. }
  182. }
  183. function work_start(){
  184. console.log("加载成功");
  185. pz.layui=unsafeWindow.layui;
  186. console.log("进入答题界面!");
  187. if (!UE) {
  188. var len = ($ || Ext.query || Array)('font:contains(未登录(不可用))', document).length;
  189. setTimeout(len == 1 ? top.location.reload : parent.greenligth, setting.time);
  190. } else if (setting.work) {
  191. setTimeout(relieveLimit, 0);
  192. beforeFind();
  193. }
  194. }
  195.  
  196. } else if (url == '/ananas/modules/audio/index.html' && setting.audio) {
  197. if (setting.review) _self.greenligth = Ext.emptyFn;
  198. _self.videojs = hookAudio;
  199. hookAudio.xhr = vjs.xhr;
  200. } else if (url == '/ananas/modules/innerbook/index.html' && setting.book && setting.tip) {
  201. setTimeout(function () {
  202. _self.setting ? _self.top.onchangepage(_self.getFrameAttr('end')) : _self.greenligth();
  203. }, setting.time);
  204. } else if (url.match(/^\/ananas\/modules\/(ppt|pdf)\/index\.html$/) && setting.docs && setting.tip) {
  205. setTimeout(function () {
  206. _self.setting ? _self.finishJob() : _self.greenligth();
  207. }, setting.time);
  208. frameElement.setAttribute('download', 1);
  209. } else if (url == '/knowledge/cards') {
  210. $ && checkToNext()
  211. } else if (url.match(/^\/(course|zt)\/\d+\.html$/)) {
  212. setTimeout(function () {
  213. +setting.read && _self.sendLogs && $('.course_section:eq(0) .chapterText').click();
  214. }, setting.time);
  215. } else if (url == '/ztnodedetailcontroller/visitnodedetail') {
  216. setting.read *= 60 / $('.course_section').length;
  217. setting.read && _self.sendLogs && autoRead();
  218. } else if (url == '/mycourse/studentcourse') {
  219. var gv = location.search.match(/d=\d+&/g);
  220. setting.total && $('<a>', {
  221. href: '/moocAnalysis/chapterStatisticByUser?classI' + gv[1] + 'courseI' + gv[0] + 'userId=' + _self.getCookie('_uid') + '&ut=s',
  222. target: '_blank',
  223. title: '点击查看章节统计',
  224. style: 'margin: 0 25px;',
  225. html: '本课程共' + $('.icon').length + '节,剩余' + $('em:not(.openlock)').length + '节未完成'
  226. }).appendTo('.zt_logo').parent().width('auto');
  227. } else if (url.match(/^\/visit\/(courses|interaction|stucoursemiddle)$/)) {
  228. setting.face && $('.zmodel').on('click', '[onclick^=openFaceTip]', DisplayURL);
  229. } else if (location.hostname == 'i.mooc.chaoxing.com') {
  230. console.log("课程页面");
  231. } else if (url == '/widget/pcvote/goStudentVotePage') {
  232. $(':checked').click();
  233. $('.StudentTimu').each(function (index) {
  234. var ans = _self.questionlist[index].answer;
  235. $(':radio, :checkbox', this).each(function (num) {
  236. ans[num].isanswer && this.click();
  237. });
  238. $(':text', this).val(function (num) {
  239. return $(ans[num].content).text().trim();
  240. });
  241. });
  242. } else if (url == '/work/selectWorkQuestionYiPiYue') {
  243. submitAnswer(getIframe().parent(), $.extend(true, [], parent._data));
  244. }else if(url =='/exam/test/reVersionTestStartNew'){
  245. console.log("考试");
  246.  
  247. kss();
  248. }
  249.  
  250. function hookVideo() {
  251. _self.alert = console.log;
  252. //console.log(arguments);
  253. var config = arguments[1];
  254. if (!config) {
  255. return vjs.apply(this, arguments);
  256. }
  257. var line = Ext.Array.filter(Ext.Array.map(config.playlines, function (value, index) {
  258. return value.label == setting.line && index;
  259. }), function (value) {
  260. return Ext.isNumber(value);
  261. }
  262. )[0] || 0,
  263. http = Ext.Array.filter(config.sources, function (value) {
  264. return value.label == setting.http;
  265. })[0];
  266. config.playbackRates = [0.5, 1, 1.5, 2, 4,6, 8, 16];
  267. config.playlines.unshift(config.playlines[line]);
  268. config.playlines.splice(line + 1, 1);
  269. config.plugins.videoJsResolutionSwitcher.default = http ? http.res : 360;
  270. config.plugins.studyControl.enableSwitchWindow = 1;
  271. config.plugins.timelineObjects.url = "/richvideo/initdatawithviewer?";
  272. config.plugins.seekBarControl.enableFastForward = 1;
  273. if (!setting.queue) delete config.plugins.studyControl;
  274.  
  275. var player = vjs.apply(this, arguments),
  276. a ='<a href="https://s1.ananas.chaoxing.com/download/' +_self.config("objectid") +'" target="_blank">',
  277. img ='<img src="https://d0.ananas.chaoxing.com/download/e363b256c0e9bc5bd8266bf99dd6d6bb" style="margin: 6px 0 0 6px;">';
  278. player.playbackRate=function (t){
  279. if(void 0===t)return "•"+this.cache_.lastPlaybackRate||this.techGet_("playbackRate");
  280. this.tech_&&this.tech_.featuresPlaybackRate?this.cache_.lastPlaybackRate||this.techGet_("playbackRate"):setting.rate;
  281. this.techCall_("setPlaybackRate",t)
  282. };
  283. player.volume(Math.round(setting.vol) / 100 || 0);
  284. player.on("loadstart", function () {
  285. setting.tip && this.play().catch(Ext.emptyFn);
  286. this.playbackRate(
  287. setting.rate > 16 || setting.rate < 0.0625 ? 1 : setting.rate
  288. );
  289. });
  290. player.one(["loadedmetadata", "firstplay"], function () {
  291. setting.two = (setting.rate === "0" || GM_getValue("fast")==1)&& setting.two < 1;
  292. setting.two &&config.plugins.seekBarControl.sendLog(this.children_[0],"ended",Math.floor(this.cache_.duration));
  293. });
  294. player.on("ended", function () {
  295. Ext.fly(frameElement).parent().addCls("ans-job-finished");
  296. });
  297.  
  298. return player;
  299. }
  300. function hookAudio() {
  301. _self.alert = console.log;
  302. var config = arguments[1];
  303. config.plugins.studyControl.enableSwitchWindow = 1;
  304. config.plugins.seekBarControl.enableFastForward = 1;
  305. if (!setting.queue) delete config.plugins.studyControl;
  306. var player = vjs.apply(this, arguments),
  307. a = '<a href="https://d0.ananas.chaoxing.com/download/' + _self.config('objectid') + '" target="_blank">',
  308. img = '<img src="https://d0.ananas.chaoxing.com/download/e363b256c0e9bc5bd8266bf99dd6d6bb" style="margin: 6px 0 0 6px;">';
  309. player.volume(Math.round(setting.vol) / 100 || 0);
  310. player.playbackRate(setting.rate > 16 || setting.rate < 0.0625 ? 1 : setting.rate);
  311. Ext.get(player.controlBar.addChild('Button').el_).setHTML(a + img + '</a>').dom.title = '下载音频';
  312. player.on('loadeddata', function () {
  313. setting.tip && this.play().catch(Ext.emptyFn);
  314. });
  315. player.one('firstplay', function () {
  316. setting.rate === '0' && config.plugins.seekBarControl.sendLog(this.children_[0], 'ended', Math.floor(this.cache_.duration));
  317. });
  318. player.on('ended', function () {
  319. Ext.fly(frameElement).parent().addCls('ans-job-finished');
  320. });
  321. return player;
  322. }
  323. function relieveLimit() {
  324. if (setting.scale) _self.UEDITOR_CONFIG.scaleEnabled = false;
  325. $.each(UE.instants, function () {
  326. var key = this.key;
  327. this.ready(function () {
  328. this.destroy();
  329. UE.getEditor(key);
  330. });
  331. });
  332. }
  333. function setting_s(){
  334. if(!pz.layer){
  335. try {
  336. pz.layui= _self.layui || top.layui;
  337. pz.layui.use('layer', function () {
  338. pz.layer=this.layer;
  339. pz.layer.closeAll();
  340.  
  341. });
  342. } catch (err) {
  343. console.log("加载失败");
  344. }
  345. }
  346. pz.queue=(setting.queue===1?"checked":"");
  347. pz.work=setting.work===1?"checked":"";
  348. pz.book=setting.book===1?"checked":"";
  349. pz.jump=setting.jump===1?"checked":"";
  350. pz.none=(setting.none==1)?"checked":"";
  351. pz.review=setting.review===1?"checked":"";
  352. pz.course=setting.course===1?"checked":"";
  353. pz.video=setting.video===1?"checked":"";
  354. pz.layer.open({
  355. type: 1,
  356. area: ['400px', '300px'],
  357. closeBtn: 1,
  358. title: "脚本参数设置",
  359. shade: 0,
  360. anim: 2,
  361. id:"sett2",
  362. content:'<script src="https://www.layuicdn.com/layui/layui.js"></script> <form class="layui-form"> <div class="layui-form-item"> <label class="layui-form-label">间隔时间</label> <div class="layui-input-inline"> <input type="number" name="time" value="'+setting.time+'" required lay-verify="required" placeholder="间隔时间" class="layui-input"> </div> <div class="layui-form-mid layui-word-aux">脚本运行间隔时间/推荐4000毫秒</div> </div> <div class="layui-form-item"> <label class="layui-form-label">视频倍率</label> <div class="layui-input-inline"> <input type="number" name="rate" value="'+setting.rate+'" required lay-verify="required" placeholder="视频倍率" class="layui-input"> </div> <div class="layui-form-mid layui-word-aux">倍速有风险,秒过需谨慎。【0秒刷,1-16倍速自己填】</div> </div> <div class="layui-form-item"> <label class="layui-form-label">队列刷课</label> <div class="layui-input-inline"> <input type="checkbox" name="queue" '+pz.queue+' lay-skin="switch"> </div> <div class="layui-form-mid layui-word-aux">开启后任务点逐一完成,关闭则单页面所有任务点同时进行</div> </div> <div class="layui-form-item"> <label class="layui-form-label">自动跳转</label> <div class="layui-input-inline"> <input type="checkbox" name="jump" '+pz.jump+' lay-skin="switch"> </div> <div class="layui-form-mid layui-word-aux">自动切换任务点、章节、课程</div> </div> <div class="layui-form-item"> <label class="layui-form-label">答案匹配</label> <div class="layui-input-inline"> <input type="checkbox" name="none" '+pz.none+' lay-skin="switch"> </div> <div class="layui-form-mid layui-word-aux">无答案是否随机答案,若有准确率需求勿开</div> </div> </form>'
  363. ,cancel: function(index,layero){
  364. $(layero[0]).find("input").each(function(){
  365. if(this.name=="time"){
  366. setting.time=this.value;
  367. GM_setValue("time",this.value);
  368. }
  369. else if(this.name=="rate"){
  370. setting.rate=this.value;
  371. GM_setValue("rate",this.value);
  372. }
  373. else{
  374. if($(this).attr("checked")){
  375. setting[this.name]=1
  376. GM_setValue(this.name,1);
  377. }else{
  378. setting[this.name]=0;
  379. GM_setValue(this.name,0);
  380. }
  381. }
  382. });
  383. console.log(setting);
  384. pz.layer.msg("保存成功!",{"icon":1});
  385. }
  386. });
  387. }
  388. function kss(){
  389. function findTiMu() {
  390. var courseId = location.search.match(/courseId=(\d+)/i)[1] || 0,
  391. classId=location.search.match(/classId=(\d+)/i)[1] || 0,
  392. zurl='http://s.jiaoyu139.com:886/get?t=ks';
  393. GM_xmlhttpRequest({
  394. method: 'POST',
  395. url: zurl,
  396. data:'keyword=' + encodeURIComponent(setting.TiMu[0]) + '&courseid='+courseId,
  397. headers: {
  398. 'Content-type': 'application/x-www-form-urlencoded',
  399. '_t': 'cx',
  400. 'referer':location.href,
  401. 'v':script_info.version,
  402. 'u':script_info.author
  403. },
  404. timeout: 5000,
  405. onload: function(xhr) {
  406. if (!setting.loop) {
  407. } else if (xhr.status == 200) {
  408. var obj = $.parseJSON(xhr.responseText) || {};
  409. obj.answer = obj.data.answer;
  410. if (obj.code) {
  411. var answer = String(obj.answer).replace(/&/g, '&').replace(/<(?!img)/g, '<'),
  412. que = setting.TiMu[0].match('<img') ? setting.TiMu[0] : setting.TiMu[0].replace(/&/g, '&').replace(/</g, '<');
  413. obj.answer = /^http/.test(answer) ? '<img src="' + obj.answer + '">' : obj.answer;
  414. setting.div.find('tbody').append(
  415. '<tr>' +
  416. '<td title="点击可复制">' + que + '</td>' +
  417. '<td title="点击可复制">' + (/^http/.test(answer) ? obj.answer : '') + answer + '</td>' +
  418. '</tr>'
  419. );
  420. setting.copy && GM_setClipboard(obj.answer);
  421. setting.$btn.eq(3).show();
  422. fillAnswer(obj);
  423. if (obj.code < 0){
  424. //alert("跳过");
  425. }else{
  426. $.ajax({
  427. type: "POST",
  428. async: false,
  429. url: "https://study.jszkk.com/api/open/add",
  430. contentType: "application/json; charset=utf-8",
  431. headers: {
  432. "Authorization":"NEFcZ1Y7g1HapKJbnMz6Y2EecNKP1e1zuYoML3mFQ1K2vGaOi9869Ac3PEeej4"
  433. },
  434. data: JSON.stringify({
  435. "content":setting.TiMu[0],
  436. "answer":obj.answer
  437. }),
  438. success: function(result) {
  439.  
  440. },
  441. error: function(result) {
  442. //alert("失败");
  443. }
  444. });
  445. }
  446. } else {
  447. $(setting.layerdom).find("#pz_tips").html(obj.answer || '服务器繁忙,正在重试...');
  448.  
  449. }
  450. $(setting.layerdom).find("#cx-notice").html(obj.msg || '');
  451. } else if (xhr.status == 403) {
  452. obj = $.parseJSON(xhr.responseText) || {};
  453. $(setting.layerdom).find("#pz_tips").html('访问限制,正在重试...');
  454. $(setting.layerdom).find('#cx-notice').html(obj.msg);
  455. //$(setting.layerdom).find("#pz_stop").click();
  456. } else {
  457. $(setting.layerdom).find("#pz_tips").html('服务器异常,正在重试...');
  458. }
  459. },
  460. ontimeout: function() {
  461. setting.loop && $(setting.layerdom).find("#pz_tips").html('服务器超时,正在重试...');
  462. }
  463. });
  464.  
  465. }
  466.  
  467. function fillAnswer(obj, tip) {
  468. var $input = $(':radio, :checkbox', '.Cy_ulBottom'),
  469. str = String(obj.answer).toCDB() || new Date().toString(),
  470. data = str.split(/#|\x01|\|/),
  471. opt = obj.opt || str,
  472. btn = $('.saveYl:contains(下一题)').offset();
  473. // $input.filter(':radio:checked').prop('checked', false);
  474. obj.code > 0 && $input.each(function(index) {
  475. if (this.value == 'true') {
  476. data.join().match(/(^|,)(False|false|正确|是|对|√|T|ri)(,|$)/) && this.click();
  477. } else if (this.value == 'false') {
  478. data.join().match(/(^|,)(False|false|错误|否|错|×|F|wr)(,|$)/) && this.click();
  479. } else {
  480. index = setting.TiMu[3][index].toCDB() || new Date().toString();
  481. index = $.inArray(index, data) + 1 || (setting.TiMu[1] == '1' && str.indexOf(index) + 1);
  482. Boolean(index) == this.checked || this.click();
  483. }
  484. }).each(function() {
  485. if (!/^A?B?C?D?E?F?G?$/.test(opt)) return false;
  486. Boolean(opt.match(this.value)) == this.checked || this.click();
  487. });
  488. if (setting.TiMu[1].match(/^[013]$/)) {
  489. tip = $input.is(':checked') || setting.none && (($input[Math.floor(Math.random() * $input.length)] || $()).click(), ' ');
  490. } else if (setting.TiMu[1].match(/^(2|[4-9]|1[08])$/)) {
  491. data = String(obj.answer).split(/#|\x01|\|/);
  492. tip = $('.Cy_ulTk textarea').each(function(index) {
  493. index = (obj.code > 0 && data[index]) || '';
  494. UE.getEditor(this.name).setContent(index.trim());
  495. }).length;
  496. tip = (obj.code > 0 && data.length == tip) || setting.none && ' ';
  497. setting.len = str.length * setting.time / 10;
  498. }
  499. if (tip == ' ') {
  500. tip = '已执行默认操作';
  501. } else if (tip) {
  502. tip = '自动答题已完成';
  503. } else if (tip === undefined) {
  504. tip = '该题型不支持自动答题';
  505. } else {
  506. tip = '未找到有效答案';
  507. }
  508. if (btn) {
  509. tip += setting.jump ? ',即将切换下一题' : ',未开启自动切换';
  510. setInterval(function() {
  511. if (!setting.jump) return;
  512. var mouse = document.createEvent('MouseEvents'),
  513. arr = [btn.left + Math.ceil(Math.random() * 80), btn.top + Math.ceil(Math.random() * 26)];
  514. mouse.initMouseEvent('click', true, true, document.defaultView, 0, 0, 0, arr[0], arr[1], false, false, false, false, 0, null);
  515. _self.event = $.extend(true, {}, mouse);
  516. delete _self.event.isTrusted;
  517. _self.getTheNextQuestion(1);
  518. }, setting.len || Math.ceil(setting.time * Math.random()) * 2);
  519. } else {
  520. $(setting.layerdom).find("#pz_sub").hide();
  521. $(setting.layerdom).find("#pz_xq").toggle();
  522. tip = '答题已完成,请自行查看答题详情';
  523. }
  524.  
  525. $(setting.layerdom).find("#pz_tips").html(tip);
  526. $(setting.layerdom).find("#pz_stop").hide().click();
  527. }
  528.  
  529. setting.notice = '公告栏';
  530. GM_xmlhttpRequest({
  531. method: 'GET',
  532. url: 'http://s.jiaoyu139.com:886/index/msg',
  533. timeout: 5000,
  534. onload: function (xhr) {
  535. if (xhr.status == 200) {
  536. var obj = $.parseJSON(xhr.responseText) || {};
  537. setting.notice = obj.msg;
  538.  
  539. $(setting.layerdom).find("#cx-notice").html( setting.notice);
  540. }
  541. },
  542. ontimeout: function () {
  543. setting.loop &&$(setting.layerdom).find("#pz_tips").html(setting.over + '服务器超时,正在重试...');
  544. }
  545. });
  546.  
  547. String.prototype.toCDB = function() {
  548. return this.replace(/\s/g, '').replace(/[\uff01-\uff5e]/g, function(str) {
  549. return String.fromCharCode(str.charCodeAt(0) - 65248);
  550. }).replace(/[“”]/g, '"').replace(/[‘’]/g, "'").replace(/。/g, '.');
  551. };
  552.  
  553. // setting.time += Math.ceil(setting.time * Math.random()) - setting.time / 2;
  554. setting.TiMu = [
  555. filterImg('.Cy_TItle .clearfix').replace(/\s*(\d+\.\d+分)$/, ''),
  556. $('[name^=type]:not([id])').val() || '-1',
  557. $('.cur a').text().trim() || '无',
  558. $('li .clearfix').map(function() {
  559. return filterImg(this);
  560. })
  561. ];
  562. if(typeof unsafeWindow.layui == 'undefined'){
  563. var Head = document.getElementsByTagName('head')[0] || document.documentElement,
  564. JQ = document.createElement('script');
  565. JQ.src = 'https://lib.baomitu.com/layui/2.6.8/layui.js';
  566. JQ.type = 'text/javascript';
  567. JQ.async = true;
  568. Head.insertBefore(JQ, Head.firstChild);
  569. GM_wait();
  570. }
  571. function GM_wait() {
  572. if (typeof unsafeWindow.layui == 'undefined') {
  573. console.log("正在加载");
  574. window.setTimeout(GM_wait, 100);
  575. } else {
  576. work_start()
  577. }
  578. }
  579. function work_start(){
  580. setting.layui=unsafeWindow.layui;
  581. if(!setting.layer){
  582. try {
  583. setting.layui= _self.layui || top.layui;
  584. setting.layui.use('layer', function () {
  585. setting.layer=this.layer;
  586. setting.layer.closeAll();
  587.  
  588. });
  589. console.log("加载成功");
  590. } catch (err) {
  591. console.log("加载失败");
  592.  
  593. }
  594. }
  595. setting.layer.open({
  596. type: 1,
  597. area: ['500px', '300px'],
  598. offset: 'lb',
  599. closeBtn: 0,
  600. title: "超星考试小助手",
  601. maxmin:true,
  602. moveOut:true,
  603. shade: 0,
  604. anim: 2,
  605.  
  606. success: function(layero, index){
  607. if(!setting.top){
  608. setting.top=layero[0].offsetTop
  609. }
  610. setting.layerdom=layero[0];
  611. setting.layerindex=index;
  612. },
  613. restore:function(){
  614. setting.layer.style(setting.layerindex, {
  615. top:setting.top,
  616. right:'0px'
  617. });
  618. },
  619. content: '<div id="msgzz" ><blockquote class="layui-elem-quote layui-quote-nm">'+
  620. '<button type="button" id="pz_stop" class="layui-btn layui-btn-normal ">暂停答题<button>'+
  621. '<button type="button" id="pz_res" class="layui-btn layui-btn-normal ">重新查询<button>'+
  622. '<button type="button" style="display: none;" id="pz_xq" class="layui-btn layui-btn-normal ">详情<button>'+
  623. '<button type="button" id="pz_sub" class="layui-btn layui-btn-normal ">' + (setting.jump ? '停止本次切换' : '开启本次切换') + '<button>'+
  624. '</blockquote><div id="pz_tips"></div>'+
  625. '<div class="layui-collapse"><div class="layui-colla-item"><h2 class="layui-colla-title">公告</h2><div class="layui-colla-content layui-show" ><div id="cx-notice">加载中...</div></div></div>'
  626. +'<div id="content"><ul></ul> <table class="layui-table"> <colgroup><col> <col> </colgroup> <thead> <tr><th>题目</th> <th>答案</th> </tr> </thead> <tbody> </tbody> </table></div></div></div>'
  627. });
  628.  
  629.  
  630. setting.div = $(setting.layerdom).appendTo('body').on('click', 'button, td', function() {
  631.  
  632. var num = setting.$btn.index(this);
  633. console.log(this.id);
  634. num=99;
  635. //console.log(num);
  636. if (num == -1) {
  637. GM_setClipboard($(this).text());
  638. } else if (this.id=="pz_stop") {
  639. if (setting.loop) {
  640. clearInterval(setting.loop);
  641. delete setting.loop;
  642. num = ['已暂停搜索', '继续答题'];
  643. } else {
  644. setting.loop = setInterval(findTiMu, setting.time);
  645. num = ['正在搜索答案...', '暂停答题'];
  646. }
  647. setting.$div.html(function() {
  648. return $(this).data('html') || num[0];
  649. }).removeData('html');
  650. $(this).html(num[1]);
  651. } else if (this.id=="pz_sub") {
  652. setting.jump = 0;
  653. setting.$div.html(function() {
  654. return arguments[1].replace('即将切换下一题', '未开启自动切换');
  655. });
  656. setting.div.find('tfoot').add(this).toggle();
  657. } else if (this.id=="pz_res") {
  658. location.reload();
  659. } else if (this.id=="pz_xq") {
  660. ($('.leftCard .saveYl')[0] || $()).click();
  661. } else if (num == 5) {
  662. setting.tk_num++;
  663. GM_setValue('tk_num_1',setting.tk_num);
  664. setting.tk_num = GM_getValue('tk_num_1');
  665. console.log(setting.tk_num);
  666. parent.location.reload();
  667. }
  668. }).detach(setting.hide ? '*' : 'html');
  669.  
  670.  
  671.  
  672. setting.$btn = setting.div.children('button');
  673. setting.$div = setting.div.children('div:eq(0)');
  674.  
  675. $(document).keydown(function(event) {
  676. if (event.keyCode == 38) {
  677. setting.div.detach();
  678. } else if (event.keyCode == 40) {
  679. setting.div.appendTo('body');
  680. }
  681. });
  682.  
  683. if (setting.scale) _self.UEDITOR_CONFIG.scaleEnabled = false;
  684. $.each(UE.instants, function() {
  685. var key = this.key;
  686. this.ready(function() {
  687. this.destroy();
  688. UE.getEditor(key);
  689. });
  690. });
  691. setting.loop = setInterval(findTiMu, setting.time);
  692.  
  693. }
  694. }
  695. function beforeFind() {
  696.  
  697. setting.regl = parent.greenligth || $.noop;
  698. if ($.type(parent._data) == 'array') return setting.regl();
  699. if(!pz.layer){
  700. try {
  701. pz.layui= _self.layui || top.layui;
  702. pz.layui.use('layer', function () {
  703. pz.layer=this.layer;
  704. pz.layer.closeAll();
  705.  
  706. });
  707. } catch (err) {
  708. console.log("加载失败");
  709. }
  710. }
  711. pz.layer.open({
  712. type: 1,
  713. area: ['500px', '300px'],
  714. offset: 'rb',
  715. closeBtn: 0,
  716. title: "超星小助手",
  717. maxmin:true,
  718. moveOut:true,
  719. shade: 0,
  720. anim: 2,
  721.  
  722. success: function(layero, index){
  723. if(!pz.top){
  724. pz.top=layero[0].offsetTop
  725. }
  726. pz.layerdom=layero[0];
  727. pz.layerindex=index;
  728. },
  729. restore:function(){
  730. pz.layer.style(pz.layerindex, {
  731. top:pz.top,
  732. right:'0px'
  733. });
  734. },
  735. content: '<div id="msgzz" ><blockquote class="layui-elem-quote layui-quote-nm">'+
  736. '<button type="button" id="pz_stop" class="layui-btn layui-btn-normal ">暂停答题<button>'+
  737. '<button type="button" id="pz_res" class="layui-btn layui-btn-normal ">重新查询<button>'+
  738. '<button type="button" id="pz_sub" class="layui-btn layui-btn-normal ">' + (setting.auto1 ? '取消本次自动提交' : '开启本次自动提交') + '<button>'+
  739. '<button type="button" id="pz_gg" class="layui-btn layui-btn-normal ">设置<button>'+
  740. '</blockquote><div id="pz_tips"></div>'+
  741. '<div class="layui-collapse"><div class="layui-colla-item"><h2 class="layui-colla-title">公告</h2><div class="layui-colla-content layui-show" ><div id="cx-notice">加载中...</div></div></div>'
  742. +'<div id="content"><ul></ul> <table class="layui-table"> <colgroup> <col width="50"> <col> <col> </colgroup> <thead> <tr> <th>序号</th> <th>题目</th> <th>答案</th> </tr> </thead> <tbody> </tbody> </table></div></div></div>'
  743. });
  744.  
  745. setting.div = $(pz.layerdom).on('click', 'button, td, input', function () {
  746. var len = $(this).prevAll('button').length;
  747. if (this.nodeName == 'TD') {
  748. $(this).prev().length && GM_setClipboard($(this).text());
  749. } else if (!$(this).siblings().length) {
  750. $(this).parent().text('正在搜索答案...');
  751. setting.num++;
  752. } else if (this.id =="pz_stop") {
  753. if (setting.loop) {
  754. clearInterval(setting.loop);
  755. delete setting.loop;
  756. len = ['已暂停搜索', '继续答题'];
  757. } else {
  758. setting.loop = setInterval(findAnswer, setting.time);
  759. len = ['正在搜索答案...', '暂停答题'];
  760. }
  761. pz.layer.title(len[0], pz.layerindex);
  762. $(this).html(len[1]);
  763. } else if (this.id == "pz_sub") {
  764. setting.auto1 = !setting.auto1;
  765. $(this).html(setting.auto1 ? '取消本次自动提交' : '开启本次自动提交');
  766. } else if (this.id == "pz_res") {
  767. parent.location.reload();
  768. } else if (this.id=="pz_gg") {
  769. setting_s();
  770. //$(pz.layerdom).find('#cx-notice').toggle();
  771. } else if (this.id == "autosubmit") {
  772. // 题目自动提交配置
  773. GM_setValue("autosubmit", this.checked);
  774. }
  775. }).end();
  776. setting.lose = setting.num = 0;
  777. setting.data = parent._data = [];
  778. setting.over = '<button style="margin-right: 10px;">跳过此题</button>';
  779. setting.curs = $('script:contains(courseName)', top.document).text().match(/courseName:\'(.+?)\'|$/)[1] || $('h1').text().trim() || '无';
  780. setting.loop = setInterval(findAnswer, setting.time);
  781. var tip = ({ undefined: '任务点排队中', null: '等待切换中' })[setting.tip];
  782. tip && $(pz.layerdom).find("#pz_stop").hide().click()&&$(pz.layerdom).find("#pz_tips").html(tip);
  783. GM_xmlhttpRequest({
  784. method: 'GET',
  785. url: 'http://s.jiaoyu139.com:886/index/msg',
  786. timeout: 5000,
  787. onload: function (xhr) {
  788. if (xhr.status == 200) {
  789. var obj = $.parseJSON(xhr.responseText) || {};
  790. setting.notice = obj.msg;
  791. $(pz.layerdom).find('#cx-notice').html(setting.notice);
  792. }
  793. },
  794. ontimeout: function () {
  795. setting.loop && pz.layer.title('服务器超时,正在重试...', pz.layerindex);
  796. }
  797. });
  798. }
  799. function findAnswer() {
  800. //$("html,body").animate({scrollTop: $('.TiMu').eq(setting.num).offset().top}, 1000);
  801. var pz_num=setting.num+1,
  802. pz_badnum=setting.lose+1;
  803. $(pz.layerdom).find("#pz_tips").html('共获取<span class="layui-bg-blue">&nbsp;' + $('.TiMu').length +'&nbsp;<\/span>道题目,正在完成第<span class="layui-bg-blue">&nbsp;' + pz_num + '&nbsp;<\/span>道题,无答案<span class="layui-bg-red">&nbsp;' + setting.lose + '&nbsp;<\/span>道题。');
  804. if (setting.num >= $('.TiMu').length) {
  805. pz.layer.title('答题已完成', pz.layerindex);
  806. var arr = setting.lose ? ['共获取<span class="layui-bg-blue">&nbsp;' + $('.TiMu').length +'&nbsp;<\/span>道题目,共<span class="layui-bg-red">&nbsp;' +setting.lose + '&nbsp;<\/span>待完成。', saveThis] : ['答题已完成,共<span class="layui-bg-blue">&nbsp;' + $('.TiMu').length +'&nbsp;<\/span>道题目', submitThis];
  807. $(pz.layerdom).find("#pz_stop").hide().click();
  808. $(pz.layerdom).find("#pz_tips").html(arr[0]);
  809. return setTimeout(arr[1], setting.time);
  810. }
  811. var $TiMu = $('.TiMu').eq(setting.num),
  812. question = filterImg($TiMu.find('.Zy_TItle:eq(0) .clearfix')).replace(/^【.*?】\s*/, '').replace(/\s*(\d+\.\d+分)$/, '').replace(/[(]\s*[)]。$/, '').replace(/(\s*)。$/, '').replace(/[(]\s*[)]$/, '').replace(/(\s*)$/, '').replace(/。$/, ''),
  813. type = $TiMu.find('input[name^=answertype]:eq(0)').val() || '-1';
  814.  
  815. if(question == ""){
  816. question = filterImg($TiMu.find('.mark_name:eq(0) .colorDeep'));
  817. }
  818. var courseId = location.search.match(/courseId=(\d+)/i)[1];
  819. var classId= location.search.match(/classId=(\d+)/i)[1];
  820. var knowledgeId=0
  821. try {
  822. knowledgeId= location.search.match(/knowledgeid=(\d+)/i)[1];
  823. } catch (err) {
  824. }
  825. GM_xmlhttpRequest({
  826. method: 'POST',
  827. url: 'http://s.jiaoyu139.com:886/get?t=zj',
  828. data: 'keyword=' + encodeURIComponent(question) + '&courseid='+courseId+'&type=' + type + '&workid=' + ($('#workRelationId').val() || $('#oldWorkId').val())+"&classid="+classId+"&knowledgeid="+knowledgeId,
  829. headers: {
  830. 'Content-type': 'application/x-www-form-urlencoded',
  831. '_t': 'cx',
  832. 'referer':location.href,
  833. 'v':script_info.version,
  834. 'u':script_info.author
  835. },
  836. timeout: 5000,
  837. onload: function (xhr) {
  838. var obj;
  839. if (!setting.loop) {
  840. } else if (xhr.status == 200) {
  841. obj = $.parseJSON(xhr.responseText) || {};
  842. obj.answer = obj.data.answer;
  843. if (obj.code) {
  844. pz.layer.title('正在搜索答案...', pz.layerindex);
  845. var td = '<td ',
  846. answer = String(obj.answer).replace(/&/g, '&').replace(/<(?!img)/g, '<');
  847. obj.answer = /^http/.test(answer) ? '<img src="' + obj.answer + '">' : obj.answer;
  848. $(
  849. '<tr>' +
  850. td + ' text-align: center;">' + $TiMu.find('.Zy_TItle:eq(0) i').text().trim() + '</td>' +
  851. td + '" title="点击可复制" >' + (question.match('<img') ? question : question.replace(/&/g, '&').replace(/</g, '&lt')) + '</td>' +
  852. td + '" title="点击可复制">' + (/^http/.test(answer) ? obj.answer : '') + answer + '</td>' +
  853. '</tr>'
  854. ).appendTo($(pz.layerdom).find('tbody')).attr("class",fillAnswer($TiMu.find('ul:eq(0)').find('li'), obj, type) ? '' :"layui-bg-red");
  855. setting.data[setting.num++] = {
  856. code: obj.code > 0 ? 1 : 0,
  857. question: question,
  858. option: obj.answer,
  859. type: Number(type)
  860. };
  861. if (obj.code < 0){
  862. }else{
  863. var j = $TiMu.find('li').length;
  864. var daa = [];
  865. var wang = obj.answer.replace(/\s+/g,"");
  866. for (var i = 0;i < j;i++){
  867. if(filterImg($TiMu.find('li').eq(i).find('p'))!=''){
  868. var da = {};
  869. da['name'] = $TiMu.find('li').eq(i).find('input').val();
  870. da['content'] = filterImg($TiMu.find('li').eq(i).find('p'));
  871. var ben = filterImg($TiMu.find('li').eq(i).find('p'));
  872. if(wang==ben){
  873. da['isanswer'] = true;
  874. }else{
  875. da['isanswer'] = false;
  876. }
  877. daa.push(da);
  878. }
  879. }
  880. if(daa.length == 0){//无选项
  881. console.log('非选择题')
  882. $.ajax({
  883. type: "POST",
  884. async: false,
  885. url: "https://study.jszkk.com/api/open/add",
  886. contentType: "application/json; charset=utf-8",
  887. headers: {
  888. "Authorization":"NEFcZ1Y7g1HapKJbnMz6Y2EecNKP1e1zuYoML3mFQ1K2vGaOi9869Ac3PEeej4"
  889. },
  890. data: JSON.stringify({
  891. "content":question,
  892. "answer":obj.answer.replace(/\s+/g,"")
  893. }),
  894. success: function(result) {
  895.  
  896. },
  897. error: function(result) {
  898. //alert("失败");
  899. }
  900. });
  901. }else{//有选项
  902. console.log('选择题')
  903. $.ajax({
  904. type: "POST",
  905. async: false,
  906. url: "https://study.jszkk.com/api/open/add",
  907. contentType: "application/json; charset=utf-8",
  908. headers: {
  909. "Authorization":"NEFcZ1Y7g1HapKJbnMz6Y2EecNKP1e1zuYoML3mFQ1K2vGaOi9869Ac3PEeej4"
  910. },
  911. data: JSON.stringify({
  912. "content":question,
  913. "answer":obj.answer.replace(/\s+/g,""),
  914. "options":daa
  915. }),
  916. success: function(result) {
  917.  
  918. },
  919. error: function(result) {
  920. //alert("失败");
  921. }
  922. });
  923. }
  924. }
  925. } else {
  926. pz.layer.title('请求失败', pz.layerindex);
  927. }
  928. } else if (xhr.status == 403) {
  929. obj = $.parseJSON(xhr.responseText) || {};
  930. setting.notice = obj.msg;
  931. $(pz.layerdom).find('#cx-notice').html(setting.notice);
  932. pz.layer.title('请求受到限制', pz.layerindex);
  933. } else {
  934. pz.layer.title('题库异常,请稍后重试', pz.layerindex);
  935. }
  936. },
  937. ontimeout: function () {
  938. setting.loop && pz.layer.title('题库超时,正在重试', pz.layerindex);
  939. }
  940. });
  941. }
  942. function jq_layer(){
  943. var Head = document.getElementsByTagName('head')[0] || document.documentElement,
  944. JQ = document.createElement('script');
  945. JQ.src = 'https://lib.baomitu.com/layui/2.6.8/layui.js';
  946. JQ.type = 'text/javascript';
  947. JQ.async = true;
  948. Head.insertBefore(JQ, Head.firstChild);
  949. }
  950. function img_cl(text){
  951. return text.replace(/https:\/\/mooc1-api.chaoxing.com/g, "").replace(/[^\u4e00-\u9fa5^\w]/g, "")
  952. }
  953. function fillAnswer($li, obj, type) {
  954. var $input = $li.find(':radio, :checkbox'),
  955. str = String(obj.answer).toCDB() || new Date().toString(),
  956. data = str.split(/#|\x01|\|/),
  957. opt = obj.opt || str,
  958. state = setting.lose;
  959. $input.prop('checked', false);
  960. // $li.find(':radio:checked').prop('checked', false);
  961. obj.code > 0 && $input.each(function (index) {
  962.  
  963. if (this.value == 'true') {
  964. data.join().match(/(^|,)(True|true|正确|是|对|√|T|ri)(,|$)/) && this.click();
  965. } else if (this.value == 'false') {
  966. data.join().match(/(^|,)(False|false|错误|否|错|×|F|wr)(,|$)/) && this.click();
  967. } else {
  968. var tip = filterImg($li.eq(index).find('.after')).toCDB() || new Date().toString();
  969. if(str.indexOf("<img") != -1 ){
  970. tip=img_cl(tip);
  971. data[0]=img_cl(data[0]);
  972. }
  973. Boolean($.inArray(tip, data) + 1 || (type == '1' && str.indexOf(tip) + 1)) == this.checked || this.click();
  974. }
  975. }).each(function () {
  976. if (!/^A?B?C?D?E?F?G?$/.test(opt)) return false;
  977. Boolean(opt.match(this.value)) == this.checked || this.click();
  978. });
  979. if (type.match(/^[013]$/)) {
  980. $input.is(':checked') || (setting.none ? ($input[Math.floor(Math.random() * $input.length)] || $()).click() : setting.lose++);
  981. } else if (type.match(/^(2|[4-9]|1[08])$/)) {
  982. data = String(obj.answer).split(/#|\x01|\|/);
  983. str = $li.end().find('textarea').each(function (index) {
  984. index = (obj.code > 0 && data[index]) || '';
  985. if (obj.code > 0) {
  986. UE.getEditor(this.name).setContent(index.trim());
  987. }
  988. }).length;
  989. (obj.code > 0 && data.length == str) || setting.none || setting.lose++;
  990. } else {
  991. setting.none || setting.lose++;
  992. }
  993. return state == setting.lose;
  994. }
  995. function saveThis() {
  996. if (!setting.auto1) return setTimeout(saveThis, setting.time);
  997. setting.div.children('button:lt(3)').hide().eq(1).click();
  998. _self.alert = console.log;
  999. $('#tempsave').click();
  1000. setting.regl();
  1001. }
  1002. function submitThis() {
  1003. if (!setting.auto1) {
  1004. } else if (!$('.Btn_blue_1:visible').length) {
  1005. setting.div.children('button:lt(3)').hide().eq(1).click();
  1006. return setting.regl();
  1007. } else if ($('#confirmSubWin:visible').length) {
  1008. var btn = $('#tipContent + * > a').offset() || { top: 0, left: 0 },
  1009. mouse = document.createEvent('MouseEvents');
  1010. btn = [btn.left + Math.ceil(Math.random() * 46), btn.top + Math.ceil(Math.random() * 26)];
  1011. mouse.initMouseEvent('click', true, true, document.defaultView, 0, 0, 0, btn[0], btn[1], false, false, false, false, 0, null);
  1012. _self.event = $.extend(true, {}, mouse);
  1013. delete _self.event.isTrusted;
  1014. _self.form1submit();
  1015. } else {
  1016. $('.Btn_blue_1')[0].click();
  1017. }
  1018. setTimeout(submitThis, Math.ceil(setting.time * Math.random()) * 2);
  1019. }
  1020. function checkToNext() {
  1021. var $tip = $(setting.job.join(', '), document).prevAll('.ans-job-icon' + setting.normal);
  1022. console.log($tip);
  1023. setInterval(function () {
  1024. console.log($tip.parent(':not(.ans-job-finished)').length);
  1025.  
  1026. if(parent.location.search.match(/mooc2=(\d+)/i)!=null){
  1027. $tip.parent(':not(.ans-job-finished)').length || setting.jump&&toNext1();
  1028. }else{
  1029. $tip.parent(':not(.ans-job-finished)').length || setting.jump&&toNext();
  1030. }
  1031. }, setting.time);
  1032. }
  1033. function toNext1(){
  1034. if($(".prev_ul").find("li.active").next().length){
  1035. $(".prev_ul").find("li.active").next().click();
  1036. }else{
  1037. var pnex=$(".posCatalog_select").slice($(".posCatalog_select").index($(".posCatalog_active"))+1).find(".jobUnfinishCount").parent().eq(0);
  1038. pnex.length||setting.course && switchCourse();
  1039. pnex.find("span").click();
  1040. }
  1041. }
  1042. function toNext() {
  1043. var $cur = $('#cur' + $('#chapterIdid').val()),
  1044. $tip = $('span.currents ~ span'),
  1045. sel = setting.review ? 'html' : '.blue';
  1046.  
  1047. if (!$cur.has(sel).length && $tip.length) return $tip.eq(0).click();
  1048. $tip = $('.roundpointStudent, .roundpoint').parent();
  1049. $tip = $tip.slice($tip.index($cur) + 1).not(':has(' + sel + ')');
  1050. $tip.not(setting.lock ? ':has(.lock)' : 'html').find('span').eq(0).click();
  1051. $tip.length || setting.course && switchCourse();
  1052. }
  1053. function switchCourse() {
  1054. console.log("课程切换");
  1055. GM_xmlhttpRequest({
  1056. method: 'POST',
  1057. url: '/visit/courselistdata',
  1058. data:"courseType=1&courseFolderId=0&courseFolderSize=0",
  1059. headers: {
  1060. 'X-Requested-With': 'XMLHttpRequest',
  1061. "Content-Type":"application/x-www-form-urlencoded; charset=UTF-8",
  1062. "Host":"mooc1-1.chaoxing.com",
  1063. "Origin":"https://mooc1-1.chaoxing.com"
  1064. },
  1065. onload: function (xhr) {
  1066.  
  1067. var list = $('h3 a[target]', xhr.responseText).map(function () {
  1068. return $(this).attr('href');
  1069. });
  1070. var index = list.map(function (index) {
  1071. return this.match(top.courseId) && index;
  1072. }).filter(function () {
  1073. return $.isNumeric(this);
  1074. })[0] + 1 || 0;
  1075. setting.course = list[index] ? goCourse(list,index) : 0;
  1076. }
  1077. });
  1078. }
  1079. function goCourse(list,index) {
  1080. url=list[index];
  1081. url="/visit"+url.split("/visit")[1];
  1082. GM_xmlhttpRequest({
  1083. method: 'GET',
  1084. url: url,
  1085. onload: function (xhr) {
  1086. var knowurl=$('h3 a[href]', xhr.responseText).attr('href');
  1087. knowurl==undefined?goCourse(list,index+1):$.globalEval('location.href = "' + $('h3 a[href]', xhr.responseText).attr('href') + '";');
  1088. }
  1089. });
  1090. }
  1091. function autoRead() {
  1092. $('html, body').animate({
  1093. scrollTop: $(document).height() - $(window).height()
  1094. }, Math.round(setting.read) * 1E3, function () {
  1095. $('.nodeItem.r i').click();
  1096. }).one('click', '#top', function (event) {
  1097. $(event.delegateTarget).stop();
  1098. });
  1099. }
  1100. function DisplayURL() {
  1101. _self.WAY.box.hide();
  1102. var $li = $(this).closest('li');
  1103. $.get('/visit/goToCourseByFace', {
  1104. courseId: $li.find('input[name=courseId]').val(),
  1105. clazzId: $li.find('input[name=classId]').val()
  1106. }, function (data) {
  1107. $li.find('[onclick^=openFaceTip]').removeAttr('onclick').attr({
  1108. target: '_blank',
  1109. href: $(data).filter('script:last').text().match(/n\("(.+?)"/)[1]
  1110. });
  1111. alert('本课程已临时解除面部识别');
  1112. }, 'html');
  1113. }
  1114. function submitAnswer($job, data) {
  1115. $job.removeClass('ans-job-finished');
  1116. data = data.length ? $(data) : $('.TiMu').map(function () {
  1117. var title = filterImg($('.Zy_TItle .clearfix', this));
  1118. return {
  1119. question: title.replace(/^【.*?】\s*/, ''),
  1120. type: ({ 单选题: 0, 多选题: 1, 填空题: 2, 判断题: 3 })[title.match(/^【(.*?)】|$/)[1]]
  1121. };
  1122. });
  1123. data = $.grep(data.map(function (index) {
  1124. var $TiMu = $('.TiMu').eq(index);
  1125. if (!($.isPlainObject(this) && this.type < 4 && $TiMu.find('.fr').length)) {
  1126. return false;
  1127. } else if (this.type == 2) {
  1128. var $ans = $TiMu.find('.Py_tk, .Py_answer').eq(0);
  1129. if (!$TiMu.find('.cuo').length && this.code) {
  1130. return false;
  1131. } else if (!$ans.find('.cuo').length) {
  1132. this.option = $ans.find('.clearfix').map(function () {
  1133. return $(this).text().trim();
  1134. }).get().join('#') || '无';
  1135. } else if (this.code) {
  1136. this.code = -1;
  1137. } else {
  1138. return false;
  1139. }
  1140. } else if (this.type == 3) {
  1141. var ans = $TiMu.find('.font20:last').text();
  1142. if ($TiMu.find('.cuo').length) {
  1143. this.option = ({ '√': '错误', '×': '正确' })[ans] || '无';
  1144. } else if (!this.code) {
  1145. this.option = ({ '√': '正确', '×': '错误' })[ans] || '无';
  1146. } else {
  1147. return false;
  1148. }
  1149. } else {
  1150. var text = $TiMu.find('.Py_answer > span:eq(0)').text();
  1151. if ($TiMu.find('.dui').length && this.code && !/^A?B?C?D?E?F?G?$/.test(this.option)) {
  1152. return false;
  1153. } else if ($TiMu.find('.dui').length || text.match('正确答案')) {
  1154. text = text.match(/[A-G]/gi) || [];
  1155. this.option = $.map(text, function (value) {
  1156. return filterImg($TiMu.find('.fl:contains(' + value + ') + a'));
  1157. }).join('#') || '无';
  1158. this.key = text.join('');
  1159. } else if (this.code) {
  1160. this.code = -1;
  1161. } else {
  1162. return false;
  1163. }
  1164. }
  1165. return this;
  1166. }), function (value) {
  1167. return value && value.option != '无';
  1168. });
  1169. setting.curs = $('script:contains(courseName)', top.document).text().match(/courseName:\'(.+?)\'|$/)[1] || $('h1').text().trim() || '无';
  1170. /* data.length && GM_xmlhttpRequest({
  1171. method: 'POST',
  1172. url: 'http://cx.icodef.com/upload/cx?workRelationId=' + $('#workId').val(),
  1173. headers: {
  1174. 'Content-type': 'application/x-www-form-urlencoded',
  1175. 'Authorization': setting.token,
  1176. },
  1177. data: 'course=' + encodeURIComponent(setting.curs) + '&data=' + encodeURIComponent((Ext.encode || JSON.stringify)(data)) + '&id=' + $('#jobid').val().slice(5)
  1178. }); */
  1179. $job.addClass('ans-job-finished');
  1180. }
  1181. function filterImg(dom) {
  1182. return $(dom).clone().find('img[src]').replaceWith(
  1183. function () {
  1184. return $('<p></p>').text('<img src="' + $(this).attr('src') + '">');
  1185. }
  1186. ).end().find('iframe[src]').replaceWith(
  1187. function () {
  1188. return $('<p></p>').text('<iframe src="' + $(this).attr('src') + '"></iframe>');
  1189. }
  1190. ).end().text().trim();
  1191. }
  1192. function getIframe(tip, win, job) {
  1193. if (!$) return Ext.get(frameElement || []).parent().child('.ans-job-icon') || Ext.get([]);
  1194. do {
  1195. win = win ? win.parent : _self;
  1196. job = $(win.frameElement).prevAll('.ans-job-icon');
  1197. } while (!job.length && win.parent.frameElement);
  1198. return tip ? win : job;
  1199. }
  1200. function jobSort($) {
  1201. var fn = $.fn ? [getIframe(1), 'length'] : [self, 'dom'],
  1202. sel = setting.job.join(', :not(.ans-job-finished) > .ans-job-icon' + setting.normal + ' ~ ');
  1203. if ($(sel, fn[0].parent.document)[0] == fn[0].frameElement) return true;
  1204. if (!getIframe()[fn[1]] || getIframe().parent().is('.ans-job-finished')) return null;
  1205. setInterval(function () {
  1206. $(sel, fn[0].parent.document)[0] == fn[0].frameElement && fn[0].location.reload();
  1207. }, setting.time);
  1208. }
  1209. function checkPlayer(tip) {
  1210. _self.videojs = hookVideo;
  1211. hookVideo.xhr = vjs.xhr;
  1212. Ext.isSogou = Ext.isIos = Ext.isAndroid = false;
  1213. var data = Ext.decode(_self.config('data')) || {};
  1214. delete data.danmaku;
  1215. data.doublespeed = 1;
  1216. frameElement.setAttribute('data', Ext.encode(data));
  1217. if (tip) return;
  1218. _self.supportH5Video = function () { return true; };
  1219. alert('此浏览器不支持html5播放器,请更换浏览器');
  1220. }

QingJ © 2025

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