// ==UserScript== // @name 青禾院-学习通助手:强势上线,完美兼容【学习通、智慧树、签到等课程】【完美匹配应付考试、测试、搜题】【搭载智能AI答题、融合智能DeepSeek模型,GPT答题库】等强大功能 // @version 3.5 // @description 青禾院学习通助手强大,支持免费视频刷 | 超星学习通 | 智慧树 | U校园 | MOOC | 继续教育类 | 优课学堂 | 考试 | 青书学堂 | 优学院 | 超星学习通 | AI解答 | 学习通 | 学习强国 | 中国大学mooc | 智慧职教 | 青书学堂 | 知到 | 乐跑 | 世界运动 | 阳光跑 | 等等课程提供学习◆可咨询群2️⃣已满:1042758197 请入咨询群3️⃣:74028813 // @author 青禾院-3.0 // @namespace https://github.com/MiXue-Lo/MiXue-ChaoXing // @license MIT // @supportURL https://github.com/MiXue-Lo/MiXue-ChaoXing/issues // @match *://*.chaoxing.com/* // @match *://*.edu.cn/* // @match *://*.nbdlib.cn/* // @match *://*.uooc.net.cn/* // @connect tk.mixuelo.cc // @run-at document-end // @grant unsafeWindow // @grant GM_xmlhttpRequest // @grant GM_setValue // @grant GM_getValue // @grant GM_info // @grant GM_getResourceText // @grant GM_notification // @grant GM_registerMenuCommand // @grant GM_openInTab // @grant GM_addStyle // @icon https://qinghy.top/upload/images/123.gif // @require https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.6.0/jquery.min.js // @require https://cdn.jsdelivr.net/npm/sweetalert2@11.7.32 // @require https://code.jquery.com/jquery-3.7.1.js5@0.8.3/src/md5.min.js // @homepage https://scriptcat.org/zh-CN/script-show-page/3038 // @compatible 浏览器为最新版本 // ==/UserScript== const API_BASE_URL = "http://tk.mixuelo.cc/api.php"; // 青禾院学习通智能助手 // 创建悬浮窗口 const floatingWindow = document.createElement('div'); floatingWindow.id = 'baidu-floating-window'; floatingWindow.style.cssText = ` position: fixed; z-index: 9999; background-color: #ffffff; border: 1px solid #e0e0e0; border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); width: 300px; height: 500px; left: 20px; top: 20px; font-family: 'Microsoft YaHei', sans-serif; overflow: hidden; display: flex; flex-direction: column; `; // const titleBar = document.createElement('div'); titleBar.style.cssText = ` padding: 12px 15px; background-color: #f5f5f5; border-bottom: 1px solid #e0e0e0; cursor: move; display: flex; justify-content: space-between; align-items: center; user-select: none; flex-shrink: 0; `; const title = document.createElement('h3'); title.textContent = '青禾院-轻量版V 2.0增强版3.0版'; title.style.cssText = ` margin: 0; font-size: 15px; color: #333; font-weight: normal; `; const closeBtn = document.createElement('span'); closeBtn.textContent = '×'; closeBtn.style.cssText = ` font-size: 20px; cursor: pointer; color: #999; line-height: 1; padding: 0 5px; `; // const navBar = document.createElement('div'); navBar.style.cssText = ` display: flex; border-bottom: 1px solid #f0f0f0; background-color: #fafafa; flex-shrink: 0; `; // const createNavButton = (text, onClick) => { const btn = document.createElement('button'); btn.textContent = text; btn.style.cssText = ` flex: 1; padding: 12px 0; background: none; border: none; cursor: pointer; font-size: 14px; color: #666; transition: all 0.3s; position: relative; `; btn.addEventListener('click', onClick); return btn; }; const homeBtn = createNavButton('首页', () => { homeContent.style.display = 'block'; settingsContent.style.display = 'none'; questionBankContent.style.display = 'none'; myContent.style.display = 'none'; description.style.display = 'block'; playButton.style.display = 'none'; }); const settingsBtn = createNavButton('设置', () => { homeContent.style.display = 'none'; settingsContent.style.display = 'block'; questionBankContent.style.display = 'none'; myContent.style.display = 'none'; description.style.display = 'block'; playButton.style.display = 'none'; }); const questionBankBtn = createNavButton('AI题库解答', () => { homeContent.style.display = 'none'; settingsContent.style.display = 'none'; questionBankContent.style.display = 'block'; myContent.style.display = 'none'; description.style.display = 'block'; playButton.style.display = 'block'; }); // const availableCourses = [ "学习通", "智慧树", "U校园", "MOOC", "学习强国", "知到", "乐跑", "优学院" ]; const myBtn = createNavButton('我的', () => { homeContent.style.display = 'none'; settingsContent.style.display = 'none'; questionBankContent.style.display = 'none'; myContent.style.display = 'block'; description.style.display = 'none'; playButton.style.display = 'none'; }); // const content = document.createElement('div'); content.style.cssText = ` padding: 15px; overflow-y: auto; flex-grow: 1; `; var setting = { showBox: 1, darkMode: 0, panelPosition: 'right', task: 0, taskInterval: 3000, video: 1, audio: 1, rate: 1, muteMedia: 0, review: 0, work: 1, time: 1000, randomTime: 0, sub: 0, force: 0, share: 0, decrypt: 1, examTurn: 0, examTurnTime: 0, goodStudent: 1, alterTitle: 1, aiMode: 'smart', aiConfidence: 80, desktopNotify: 1, soundNotify: 0, autoLogin: 0, phone: '', password: '' } var M=unsafeWindow,I=location,Se=M.document,i=M.jQuery||top.jQuery,ye=ye||window.md5,D=M.UE,oe="",oe="http://tk.mixuelo.cc",S,G,E,H,ne,U,pe=0;const be=document.createElement("style");be.textContent=` .gpt-box { position: fixed; top: 10px; right: 10px; width: 300px; max-height: 400px; overflow-y: auto; background: rgba(255, 255, 255, 0.95); border-radius: 10px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); z-index: 9999; padding: 15px; font-family: "Microsoft YaHei", sans-serif; transition: all 0.3s ease; border-left: 4px solid #FC3A72; animation: slideIn 0.5s ease; } @keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } } .gpt-box:hover { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2); transform: translateY(-2px); } .gpt-box::-webkit-scrollbar { width: 6px; } .gpt-box::-webkit-scrollbar-thumb { background: #FC3A72; border-radius: 3px; } .gpt-message { margin: 8px 0; padding: 8px 12px; border-radius: 6px; font-size: 14px; line-height: 1.5; word-break: break-all; } .gpt-message.pink { background: #fce4ec; color: #e91e63; border-left: 4px solid #e91e63; } .gpt-message.orange { background: #fff3e0; color: #ff9800; border-left: 4px solid #ff9800; } .gpt-message.red { background: #ffebee; color: #f44336; border-left: 4px solid #f44336; } .gpt-message.purple { background: #f3e5f5; color: #9c27b0; border-left: 4px solid #9c27b0; } `;document.head.appendChild(be);function n(e,t="black"){var a;let s=document.querySelector(".gpt-box");s||(s=document.createElement("div"),s.className="gpt-box",localStorage.getItem("GPTJsSetting.hideGptBox")==="true"&&(s.style.display="none"),document.body.appendChild(s));let r=e;if(e.includes("发送请求数据:"))try{const d=e.substring(e.indexOf("{")),f=JSON.parse(d),g=f.model,m=((a=f.messages.find(b=>b.role==="user"))==null?void 0:a.content)||"";r=`发送请求:使用模型 ${g},问题:"${m.substring(0,50)}${m.length>50?"...":""}"`}catch{}else if(e.includes("收到响应:"))try{const d=e.substring(e.indexOf("{"),e.lastIndexOf("}")+1),f=JSON.parse(d);f.code===200?r="收到响应:请求成功,服务器状态正常":r=`收到响应:${f.msg||"服务器返回未知状态"}`}catch{r="收到服务器响应"}const o=document.createElement("div");o.className=`gpt-message ${t}`,o.innerHTML=r,s.appendChild(o),s.scrollTop=s.scrollHeight}window.onload=function(){localStorage.getItem("GPTJsSetting.showBox")=="hide"?(i("#ne-21box").css("display","none"),i("#ne-21box").css("opacity","0")):(i("#ne-21box").css("display","block"),i("#ne-21box").css("opacity","1"));const e=i("#modelSelect");e.on("change",function(){const s=e.val();localStorage.setItem("GPTJsSetting.model",s)});const t=localStorage.getItem("GPTJsSetting.model");t&&e.val(t)};i(document).keydown(function(e){e.keyCode==120&&i("#ne-21notice")[0]!=null&&(localStorage.getItem("GPTJsSetting.showBox")=="hide"?(i("#ne-21box").css("display",show="block"),i("#ne-21box").css("opacity","1"),localStorage.setItem("GPTJsSetting.showBox","show")):(i("#ne-21box").css("display",show="none"),localStorage.setItem("GPTJsSetting.showBox","hide")))});i(".navshow").find("a:contains(体验新版)")[0]&&i(".navshow").find("a:contains(体验新版)")[0].click();setting.decrypt&&Ze();if(!(I.hostname=="i.mooc.chaoxing.com"||I.hostname=="i.chaoxing.com"))if(I.pathname=="/login"&&setting.autoLogin)F(),setTimeout(()=>{Ge()},3e3);else if(I.pathname.includes("/mycourse/studentstudy"))F(),i("#ne-21log",window.parent.document).html("初始化完毕!");else if(I.pathname.includes("/knowledge/cards")){var R=Pe();R==null||R=="$mArg"||i.parseJSON(R).attachments.length<=0?(n("无任务点可处理,即将跳转页面","red"),L()):setTimeout(()=>{top.checkJob&&(top.checkJob=()=>!1),E=[],S=i.parseJSON(R).attachments,G=i.parseJSON(R).defaults,i.each(i(".wrap .ans-cc .ans-attach-ct"),(e,t)=>{E.push(i(t).find("iframe"))}),O()},3e3)}else I.pathname.includes("/exam/test/reVersionTestStartNew")?(F(),setTimeout(()=>{$e()},3e3)):I.pathname.includes("/exam/test/reVersionPaperMarkContentNew")?setting.share&&(F(),setTimeout(()=>{qe()},3e3)):I.pathname.includes("/mooc2/work/dowork")?(F(),setTimeout(()=>{Fe()},3e3)):I.pathname.includes("/mooc2/work/view")?setting.share&&(F(),setTimeout(()=>{Ke()},3e3)):I.pathname.includes("/work/phone/doHomeWork")?(_oldal=M.alert,M.alert=function(e){if(e!="保存成功")return _oldal(e)},_oldcf=M.confirm,M.confirm=function(e){return e.includes("确认提交")||e.includes("未做完")?!0:_oldcf(e)}):I.pathname.includes("/mooc2/exam/exam-list")||I.pathname=="/mycourse/stu"&&ve();function ve(){var e=navigator.userAgent;e.indexOf("Chrome")==-1||GM_info.scriptHandler!="ScriptCat"}function _e(e){return _url=e.replace(/^http:/,"https:"),_url}function Ie(){let t=window.location.search.substring(1).split("&"),s={};for(let r=0;rs)return}var Y=document.getElementById("moreSettingsBtn"),le=document.getElementById("moreSettings"),ce=document.getElementById("userInfo"),$=!1;Y.addEventListener("click",function(){ce.style.display=$?"block":"none",le.style.display=$?"none":"block",de.style.display="none",ue.style.display="none",Y.textContent=$?"设置":"返回",$&&(W.textContent="AI功能",X.textContent="教程"),$=!$,q=!1,j=!1});var W=document.getElementById("newFeatureBtn"),de=document.getElementById("newFeaturePanel"),q=!1;W.addEventListener("click",function(){ce.style.display=q?"block":"none",de.style.display=q?"none":"block",le.style.display="none",ue.style.display="none",W.textContent=q?"AI功能":"返回",q&&(Y.textContent="设置",X.textContent="教程"),q=!q,$=!1,j=!1});var X=document.getElementById("tutorialBtn"),ue=document.getElementById("tutorialPanel"),j=!1;X.addEventListener("click",function(){ce.style.display=j?"block":"none",ue.style.display=j?"none":"block",le.style.display="none",de.style.display="none",X.textContent=j?"教程":"返回",j&&(Y.textContent="设置",W.textContent="AI功能"),j=!j,$=!1,q=!1});["sub","force","examTurn","goodStudent","alterTitle","hideGptBox","notification","skipTest","useAI","randomAnswer","useTiku"].forEach(function(e){var t=document.getElementById("GPTJsSetting."+e);t.addEventListener("change",Ae),t.checked=localStorage.getItem("GPTJsSetting."+e)==="true",localStorage.getItem("GPTJsSetting."+e)===null&&(e==="sub"?(localStorage.setItem("GPTJsSetting."+e,setting.sub?"true":"false"),t.checked=setting.sub===1):e==="force"?(localStorage.setItem("GPTJsSetting."+e,setting.force?"true":"false"),t.checked=setting.force===1):e==="alterTitle"?localStorage.setItem("GPTJsSetting."+e,"true"):e==="hideGptBox"?localStorage.setItem("GPTJsSetting."+e,"false"):e==="notification"?localStorage.setItem("GPTJsSetting."+e,"true"):e==="skipTest"||e==="useAI"||e==="randomAnswer"?localStorage.setItem("GPTJsSetting."+e,"false"):e==="useTiku"&&localStorage.setItem("GPTJsSetting."+e,"true")),e==="hideGptBox"&&t.checked&&document.querySelectorAll(".gpt-box").forEach(r=>{r.style.display="none"})});function Ae(e){var t=e.target;localStorage.setItem(t.id,t.checked),t.id==="GPTJsSetting.hideGptBox"&&document.querySelectorAll(".gpt-box").forEach(r=>{r.style.display=t.checked?"none":"block"})}const V=document.getElementById("GPTJsSetting.model");if(V){const e=localStorage.getItem("GPTJsSetting.model");e?V.value=e:localStorage.setItem("GPTJsSetting.model",V.value),V.addEventListener("change",function(){localStorage.setItem("GPTJsSetting.model",this.value),n("AI模型已更改为: "+this.value,"#1890ff")})}const Q=document.getElementById("GPTJsSetting.model");if(Q){const e=localStorage.getItem("GPTJsSetting.model");e?Q.value=e:localStorage.setItem("GPTJsSetting.model",Q.value),Q.addEventListener("change",function(){localStorage.setItem("GPTJsSetting.model",this.value),n("AI模型已更改为: "+this.value,"#1890ff")})}function F(){const e=document.querySelector(".gpt-box");if(e&&(e.style.display=e.style.display==="none"?"block":"none"),setting.showBox&&top.document.querySelector("#ne-21notice")==null){var t=`

青禾院学习通助手

F9显隐面板

AI 助手

选择模型:
输入问题:
AI 回答:
AI 助手已准备就绪,请输入您的问题...
控制日志窗口显示/隐藏
`;i(t).appendTo("body"),i("#ne-21close").click(function(){let o=i("#ne-21box").css("display");i("#ne-21box").css("display",o=="block"?"none":"block"),o=="block"?(i(".tiku-settings-btn").parent().css("display","flex"),Y.textContent="设置",W.textContent="AI功能",X.textContent="教程",$=!1,q=!1,j=!1):i(".tiku-settings-btn").parent().css("display","none")}),i("#GPTJsSetting\\.key").val(localStorage.getItem("GPTJsSetting.key")||"");const r=localStorage.getItem("GPTJsSetting.notification")!=="false";i("#GPTJsSetting\\.notification").prop("checked",r),i("#GPTJsSetting\\.notification").change(function(){localStorage.setItem("GPTJsSetting.notification",this.checked);const o=document.getElementById("saveKeyMsg");o.innerText=this.checked?"桌面通知已开启":"桌面通知已关闭",o.style.backgroundColor=this.checked?"#4CAF50":"#FF9800",o.style.display="block",setTimeout(function(){o.style.opacity="1",o.style.transform="translateY(0)"},10),setTimeout(function(){o.style.opacity="0",o.style.transform="translateY(-10px)",setTimeout(function(){o.style.display="none"},300)},3e3)}),i("#saveKeyBtn").click(function(){const o=i("#GPTJsSetting\\.key").val().trim();if(!o){const a=document.getElementById("saveKeyMsg");a.innerText="请输入Key!",a.style.backgroundColor="#f44336",a.style.display="block",setTimeout(function(){a.style.opacity="1",a.style.transform="translateY(0)"},10),J("请输入Key!","请输入Key!",""),setTimeout(function(){a.style.opacity="0",a.style.transform="translateY(-10px)",setTimeout(function(){a.style.display="none"},300)},3e3);return}GM_xmlhttpRequest({url:API_BASE_URL+"?act=verify_key",method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:"key="+encodeURIComponent(o),onload:function(a){try{const d=JSON.parse(a.responseText),f=document.getElementById("saveKeyMsg");d.code===1?(localStorage.setItem("GPTJsSetting.key",o),localStorage.setItem("tiku_key",o),f.innerText="API Key 保存成功!",f.style.backgroundColor="#4CAF50",f.style.display="block",setTimeout(function(){f.style.opacity="1",f.style.transform="translateY(0)"},10),J("API Key 保存成功!","您的API Key已成功保存","")):(f.innerText=d.msg||"Key验证失败",f.style.backgroundColor="#f44336",f.style.display="block",setTimeout(function(){f.style.opacity="1",f.style.transform="translateY(0)"},10),J("Key验证失败",d.msg||"Key验证失败","")),setTimeout(function(){f.style.opacity="0",f.style.transform="translateY(-10px)",setTimeout(function(){f.style.display="none"},300)},3e3)}catch{alert("验证请求失败,请稍后重试")}},onerror:function(){alert("验证请求失败,请检查网络连接")}})})}else i("#ne-21log",window.parent.document).html("");let s=ge("_uid")||ge("UID");i("#ne-21notice").html(`
当前学习通账号UID:`+s+`
此脚本为青禾院3.0版本-学习通课程,如需要更多课程请注册青禾院平台获取课程及考试密钥。脚本为公开,请勿长时间挂机,合理使用:
联系方式QQ群:1042758197或74028813
站长专属q:417545796
切记获取 key 请联系站长
`),GM_xmlhttpRequest({method:"GET",url:oe+"/api/v1/auth?uid="+s+"&v="+GM_info.script.version,timeout:1e4,onload:function(r){if(r.status==200){var o=i.parseJSON(r.responseText)||{},a=o.data.notice,d=o.data.score;if(i("#userInfo").html(a+"积分余额:"+d),o.data.models){var f=i("#modelSelect").val();i("#modelSelect").html(o.data.models),i("#modelSelect").val(f)}}},ontimeout:function(){i("#userInfo").html("欢迎使用,获取服务器公告超时!")}})}function re(e,t,s){let r=e.match(new RegExp(`${t}(.*?)${s}`));return r?r[1]:null}function Pe(){try{var e=Se.scripts,t=null;for(let s=0;s{i("#phone").val(setting.phone),i("#pwd").val(setting.password),i("#loginBtn").click()},3e3)}function L(){je().then(e=>{if(setting.review||!setting.work){setTimeout(()=>{if(i("#ne-21log",window.parent.document).html(""),top.document.querySelector("#mainid > .prev_next.next")==null){top.document.querySelector("#prevNextFocusNext").click();return}top.document.querySelector("#mainid > .prev_next.next").click()},5e3);return}let t=[];i.each(i(e).find("li"),(o,a)=>{let d=i(a).find(".posCatalog_select").attr("id"),f=i(a).find(".prevHoverTips").text(),g=i(a).find(".posCatalog_name").attr("title");d.indexOf("cur")!=-1&&t.push({curid:d,status:f,name:g})});let s=i("#coursetree",window.parent.document).find(".posCatalog_active").attr("id"),r=t.findIndex(o=>o.curid==s);for(r;r{if(i("#ne-21log",window.parent.document).html(""),top.document.querySelector("#mainid > .prev_next.next")==null){top.document.querySelector("#prevNextFocusNext").click();return}top.document.querySelector("#mainid > .prev_next.next").click()},5e3);return}}let o=t[r+1];if(o.status.indexOf("待完成")!=-1){J("准备切换下一个任务",`即将切换到: ${o.name}`,""),setTimeout(()=>{if(i("#ne-21log",window.parent.document).html(""),top.document.querySelector("#mainid > .prev_next.next")==null){top.document.querySelector("#prevNextFocusNext").click();return}top.document.querySelector("#mainid > .prev_next.next").click(),F()},5e3);return}else if(o.status.indexOf("闯关")!=-1){n("当前为闯关模式,存在未完成任务点,脚本已暂停运行,请手动完成并点击下一章节","red");return}else if(o.status.indexOf("开放")!=-1){n("章节未开放","red");return}}J("课程完成","此课程所有任务点已处理完毕",""),n("此课程处理完毕","green")})}function O(){try{if(F(),S.length<=0)return J("任务点完成","此页面所有任务点已处理完毕,准备跳转页面",""),n("此页面任务处理完毕,准备跳转页面","green"),L();let e=S[0].type,t=E[0],s=S[0];switch(e==null&&(e=S[0].property.module),n("正在处理任务类型: "+e,"blue"),e){case"video":if(S[0].property.module=="insertvideo"){n("开始处理视频","purple"),Ce(t,s);break}else if(S[0].property.module=="insertaudio"){n("开始处理音频","purple"),Ee(t,s);break}else{n("未知类型任务,请联系作者,跳过","red"),T();break}case"workid":if(n("开始处理测验","purple"),localStorage.getItem("GPTJsSetting.skipTest")==="true")return n("已设置不做测验,跳过测验任务","orange"),L();ze(t,s);break;case"document":n("开始处理文档","purple"),Be(t,s);break;case"read":n("开始处理阅读","purple"),Oe(t,s);break;case"insertbook":n("开始处理读书","purple"),Je(t,s);break;default:["insertimage"].indexOf(e)!=-1?(n("发现无需处理任务,跳过。","red"),T()):(n("暂不支持处理此类型:"+e+",跳过。","red"),T())}}catch(e){n("初始化任务系统出错: "+e,"red");try{S&&S.length>0&&S.splice(0,1),E&&E.length>0&&E.splice(0,1),n("将在5秒后尝试继续执行任务系统","orange"),setTimeout(()=>{try{O()}catch(t){n("无法恢复任务系统,请刷新页面: "+t,"red")}},5e3)}catch(t){n("恢复过程失败,请刷新页面: "+t,"red")}}}function Ee(e,t){if(!setting.audio){n("用户设置不处理音频任务,准备开始下一个任务。","red");try{T()}catch(r){n("音频任务切换失败: "+r,"red"),setTimeout(()=>{try{T()}catch{n("使用initializeTaskSystem作为备选","orange"),setTimeout(O,2e3)}},3e3)}return}let s;if(setting.task?(n("当前只处理任务点任务","red"),t.jobid!=null?s=!0:s=!1):(n("当前默认处理所有任务(包括非任务点任务)","red"),s=!0),s){let r=G.clazzId,o=G.userid,a=G.fid,d=G.reportUrl,f=t.isPassed,g=t.otherInfo,m=t.property._jobid,b=t.property.name,x=t.property.objectid;if(setting.maskImg){let h=i(e).attr("style");i(e).contents().find("body").find(".main").attr("style","visibility:hidden;"),i(e).contents().find("body").prepend('')}if(!setting.review&&f==!0){n("音频:"+b+"检测已完成,准备处理下一个任务","green"),T();return}else setting.review&&n("已开启复习模式,开始处理音频:"+b,"pink");i.ajax({url:I.protocol+"//"+I.host+"/ananas/status/"+x+"?k="+a+"&flag=normal&_dc="+String(Math.round(new Date)),type:"GET",success:function(h){try{let u=h.duration,c=h.dtoken,p="0_"+u,y=0,k=3;var l=.9;setting.rate==0?(n("已开启音频秒过,99.9%会导致进度重置、挂科等问题。","red"),n("已开启音频秒过,请等待5秒!!!","red")):setting.rate>1&&setting.rate<=16?(n("已开启音频倍速,当前倍速:"+setting.rate+",99.9%会导致进度重置、挂科等问题。","red"),n("已开启音频倍速,进度40秒更新一次,请等待!","red")):setting.rate>16?(setting.rate=1,n("超过允许设置的最大倍数,已重置为1倍速。","red")):n("音频进度每隔40秒更新一次,请等待耐心等待...","blue"),n("音频:"+b+"开始播放"),he(d,c,r,y,u,p,x,g,m,o,k,l).then(w=>{switch(w){case 1:n("音频:"+b+"已播放"+String(y/u*100).slice(0,4)+"%","purple"),k=0;break;case 3:l=1;break;default:console.log(w)}});let v=setInterval(()=>{y+=40*setting.rate,y>=u||setting.rate==0?(clearInterval(v),y=u,k=4):(rt=y==40*setting.rate)?k=3:k=0,he(d,c,r,y,u,p,x,g,m,o,k,l).then(w=>{switch(w){case 0:y-=40;break;case 1:n("音频:"+b+"已播放"+String(y/u*100).slice(0,4)+"%","purple");break;case 2:clearInterval(v),n("音频:"+b+"检测播放完毕,准备处理下一个任务。","green"),T();break;case 3:y-=40,l=Number(l)==1?.9:1;break;default:console.log(w)}})},setting.rate==0?5e3:4e4)}catch(u){n("发生错误:"+u,"red")}}})}else{n("用户设置只处理属于任务点的任务,准备处理下一个任务","green"),T();return}}function Ce(e,t){if(!setting.video){n("用户设置不处理视频任务,准备开始下一个任务。","red");try{T()}catch(f){n("视频任务切换失败: "+f,"red"),setTimeout(()=>{try{T()}catch{n("使用initializeTaskSystem作为备选","orange"),setTimeout(O,2e3)}},3e3)}return}G.clazzId,G.userid,G.fid,G.reportUrl;let s=t.isPassed;t.otherInfo,t.property._jobid;let r=t.property.name;if(t.property.objectid,!setting.review&&s==!0){n("视频:"+r+"检测已完成,准备处理下一个任务","green"),T();return}const o=i("iframe").get(0),a=o.src,d=o.contentDocument;if(a.includes("video")){n("发现一个视频,正在解析");let f=!1;const g=setInterval(()=>{const m=d.documentElement.querySelector("video");if(m&&!f){if(n("播放成功"),!m)return;m.pause(),m.muted=!0,m.play();const b=()=>{me(2e3).then(()=>{m.play()})};m.addEventListener("pause",b),m.addEventListener("ended",()=>{n("视频已播放完成"),m.removeEventListener("pause",b),resolve()}),f=!0,clearInterval(g)}},2500)}else if(a.includes("audio")){n("发现一个音频,正在解析");let f=!1;const g=setInterval(()=>{const m=d.documentElement.querySelector("audio");if(m&&!f){if(n("播放成功"),!m)return;m.pause(),m.muted=!0,m.play();const b=()=>{me(2e3).then(()=>{m.play()})};m.addEventListener("pause",b),m.addEventListener("ended",()=>{n("音频已播放完成"),m.removeEventListener("pause",b),resolve()}),f=!0,clearInterval(g)}},2500)}}function Je(e,t){if(setting.task&&t.jobid==null){n("当前只处理任务点任务,跳过","red");try{T()}catch(g){n("书籍任务切换失败: "+g,"red"),setTimeout(()=>{try{T()}catch{n("使用initializeTaskSystem作为备选","orange"),setTimeout(O,2e3)}},3e3)}return}let s=t.property.jobid,r=t.property.bookname,o=t.jtoken,a=G.knowledgeid,d=G.courseid,f=G.clazzId;if(t.job==null){n("读书:"+r+"检测已完成,准备执行下一个任务。","green"),T();return}i.ajax({url:I.protocol+"//"+I.host+"/ananas/job?jobid="+s+"&knowledgeid="+a+"&courseid="+d+"&clazzid="+f+"&jtoken="+o+"&_dc="+String(Math.round(new Date)),method:"GET",success:function(g){g.status?n("读书:"+r+g.msg+",准备执行下一个任务。","green"):n("读书:"+r+"处理异常,跳过。","red"),T()}})}function Be(e,t){if(setting.task&&t.jobid==null){n("当前只处理任务点任务,跳过","red"),T();return}let s=t.property.jobid,r=t.property.name,o=t.jtoken,a=G.knowledgeid,d=G.courseid,f=G.clazzId;if(t.job==null){n("文档:"+r+"检测已完成,准备执行下一个任务。","green");try{T()}catch(g){n("文档任务切换失败: "+g,"red"),setTimeout(()=>{try{T()}catch{n("使用initializeTaskSystem作为备选","orange"),setTimeout(O,2e3)}},3e3)}return}i.ajax({url:I.protocol+"//"+I.host+"/ananas/job/document?jobid="+s+"&knowledgeid="+a+"&courseid="+d+"&clazzid="+f+"&jtoken="+o+"&_dc="+String(Math.round(new Date)),method:"GET",success:function(g){g.status?n("文档:"+r+g.msg+",准备执行下一个任务。","green"):n("文档:"+r+"处理异常,跳过。","red");try{T()}catch(m){n("文档任务切换失败: "+m,"red"),setTimeout(()=>{try{T()}catch{n("使用initializeTaskSystem作为备选","orange"),setTimeout(O,2e3)}},3e3)}}})}function Oe(e,t){if(setting.task&&t.jobid==null){n("当前只处理任务点任务,跳过","red");try{T()}catch(g){n("阅读任务切换失败: "+g,"red"),setTimeout(()=>{try{T()}catch{n("使用initializeTaskSystem作为备选","orange"),setTimeout(O,2e3)}},3e3)}return}let s=t.property.jobid,r=t.property.title,o=t.jtoken,a=G.knowledgeid,d=G.courseid,f=G.clazzId;if(t.job==null){n("阅读:"+r+",检测已完成,准备执行下一个任务。","green");try{T()}catch(g){n("阅读任务切换失败: "+g,"red"),setTimeout(()=>{try{T()}catch{n("使用initializeTaskSystem作为备选","orange"),setTimeout(O,2e3)}},3e3)}return}i.ajax({url:I.protocol+"//"+I.host+"/ananas/job/readv2?jobid="+s+"&knowledgeid="+a+"&courseid="+d+"&clazzid="+f+"&jtoken="+o+"&_dc="+String(Math.round(new Date)),method:"GET",success:function(g){g.status?n("阅读:"+r+g.msg+",准备执行下一个任务。","green"):n("阅读:"+r+"处理异常,跳过。","red");try{T()}catch(m){n("阅读任务切换失败: "+m,"red"),setTimeout(()=>{try{T()}catch{n("使用initializeTaskSystem作为备选","orange"),setTimeout(O,2e3)}},3e3)}}})}function ze(e,t){if(!setting.work){n("用户设置不自动处理测验,准备处理下一个任务","green");try{T()}catch(o){n("测验任务切换失败: "+o,"red"),setTimeout(()=>{try{T()}catch{n("使用initializeTaskSystem作为备选","orange"),setTimeout(O,2e3)}},3e3)}return}let s;if(setting.task)if(n("当前只处理任务点任务","red"),t.jobid!=null)s=!0;else{s=!1;try{n("非任务点测验,跳过","orange"),T()}catch(o){n("任务切换失败: "+o,"red"),setTimeout(O,3e3)}return}else n("当前默认处理所有任务(包括非任务点任务)","red"),s=!0;if(s)if(t.jobid!==void 0){var r=I.protocol+"//"+I.host+"/work/phone/work?workId="+t.jobid.replace("work-","")+"&courseId="+G.courseid+"&clazzId="+G.clazzId+"&knowledgeId="+G.knowledgeid+"&jobId="+t.jobid+"&enc="+t.enc;setTimeout(()=>{ee(0,e,r)},3e3)}else setTimeout(()=>{N(0,e)},3e3);else{n("用户设置只处理属于任务点的任务,准备处理下一个任务","green"),T();return}}function De(e){let t=e.find(".Wrappadding form");H=t.find(".zquestions .zsubmit .btn-ok-bottom"),$okBtn=e.find("#okBtn"),ne=t.find(".zquestions .zsubmit .btn-save");let s=t.find(".zquestions .Py-mian1");A(0,s)}function A(e,t){if(e==t.length){localStorage.getItem("GPTJsSetting.sub")==="true"?(n("测验处理完成,准备自动提交。","green"),setTimeout(()=>{H.click(),setTimeout(()=>{n("提交成功,准备切换下一个任务。","green"),S.splice(0,1),E.splice(0,1),setTimeout(()=>{T()},3e3)},3e3)},5e3)):localStorage.getItem("GPTJsSetting.force")==="true"?(n("测验处理完成,存在无答案题目,由于用户设置了强制提交,准备自动提交。","red"),setTimeout(()=>{H.click(),setTimeout(()=>{$okBtn.click(),n("提交成功,准备切换下一个任务。","green"),S.splice(0,1),E.splice(0,1),setTimeout(()=>{T()},3e3)},3e3)},5e3)):(n("测验处理完成,存在无答案题目或用户设置不自动提交,自动保存!","green"),setTimeout(()=>{n("保存成功,准备切换下一个任务。","green"),ne.click(),setTimeout(()=>{n("保存成功,准备切换下一个任务。","green"),S.splice(0,1),E.splice(0,1);try{n("正在执行任务切换...","blue"),O()}catch(b){n("任务切换出错: "+b,"red"),setTimeout(()=>{try{T()}catch(x){n("通过switchMission切换任务也失败: "+x,"red"),n("将在5秒后重试,如仍失败请刷新页面","orange"),setTimeout(()=>{try{L()}catch{n("无法自动切换,请手动切换到下一任务","red")}},5e3)}},3e3)}},3e3)},5e3));return}let s=i(t[e]).find(".Py-m1-title").html(),r=K(s).replace(/.*?\[.*?题\]\s*\n\s*/,"").trim(),o={单选题:0,多选题:1,填空题:2,判断题:3,简答题:4,选择题:5}[s.match(/.*?\[(.*?)]|$/)[1]],a=[],d;var f=0;switch(o){case 0:d=i(t[e]).find(".answerList.singleChoice li");var m=[];d.each(function(){var l=i(this).text().replace(/[ABCD]/g,"").trim();m.push(l)}),m=m.join("|"),n("单选题: "+r+` `+m,"blue");let b=r;for(var g=0;g{A(e+1,t)},300);break}f==0&&_(o,b).then(l=>{d=i(t[e]).find(".answerList.singleChoice li"),i.each(d,(c,p)=>{a.push(P(i(p).html()).replace(/^[A-Z]\s*\n\s*/,"").trim())});let u=-1;if(!l||l.trim()===""){n("未获取到有效答案,跳过此题","red"),localStorage.setItem("GPTJsSetting.sub",!1),setTimeout(()=>{A(e+1,t)},setting.time);return}if(/^[A-D]$/i.test(l.trim())){let c=l.trim().toUpperCase().charCodeAt(0)-65;c>=0&&c=0&&pc==l),u==-1&&!l.includes("未找到答案")&&l!=="暂无答案"){for(let c=0;c{A(e+1,t)},setting.time)):(i(d[u]).click(),n("自动答题成功,准备切换下一题","green"),setTimeout(()=>{A(e+1,t)},setting.time))}).catch(l=>{n("答案获取失败,跳过此题","red"),l.c==0&&setTimeout(()=>{A(e+1,t)},setting.time)});break;case 1:d=i(t[e]).find(".answerList.multiChoice li");var m=[];d.each(function(){var l=i(this).text().replace(/[ABCD]/g,"").trim();m.push(l)}),m=m.join("|"),n("多选题: "+r+` `+m,"blue");let x=r;for(var g=0;g{A(e+1,t)},300);break}f==0&&_(o,x).then(l=>{if(!l||l.trim()===""||l.includes("未找到答案")||l==="暂无答案"){n("未获取到有效答案,跳过此题","red"),localStorage.setItem("GPTJsSetting.sub",!1),setTimeout(()=>{A(e+1,t)},setting.time);return}else{if(d=i(t[e]).find(".answerList.multiChoice li"),/^[A-D]+$/i.test(l.trim())){let c=l.trim().toUpperCase().split("");n("识别到多选题选项字母: "+c.join(","),"green"),c.forEach(p=>{let y=p.charCodeAt(0)-65;y>=0&&y{i(d[y]).click()},300)})}else if(/答案:?[A-D]+/i.test(l)){let c=l.match(/答案:?([A-D]+)/i);if(c&&c[1]){let p=c[1].toUpperCase().split("");n("从答案文本中提取选项: "+p.join(","),"green"),p.forEach(y=>{let k=y.charCodeAt(0)-65;k>=0&&k{i(d[k]).click()},300)})}}else i.each(d,(c,p)=>{let y=P(i(p).html()).replace(/^[A-Z]\s*\n\s*/,"").trim();l.indexOf(y)!=-1&&setTimeout(()=>{i(d[c]).click()},300)});let u=0;setTimeout(()=>{i.each(d,(c,p)=>{i(p).attr("class").indexOf("cur")!=-1&&(u=1)}),u?n("自动答题成功,准备切换下一题","green"):(n("未能正确选择答案,请手动选择,跳过此题","red"),localStorage.setItem("GPTJsSetting.sub",!1)),setTimeout(()=>{A(e+1,t)},setting.time)},1e3)}}).catch(l=>{l.c==0&&setTimeout(()=>{A(e+1,t)},setting.time)});break;case 2:let h=i(t[e]).find(".blankList2 input");if(i(h).val()!==null){n("此题已作答,跳过","green"),setTimeout(()=>{A(e+1,t)},300);break}_(o,r).then(l=>{if(l=="暂无答案"||l===""){n("AI无法完美匹配正确答案,请手动选择,跳过此题","red"),localStorage.setItem("GPTJsSetting.sub",!1),setTimeout(()=>{A(e+1,t)},setting.time);return}let u=l;if(u.includes("答案:")){let y=u.split("答案:");y.length>1&&(u=y[1].trim(),u=u.split(/[\n\r]+/)[0].trim(),n("从AI回答中提取填空答案: "+u,"green"))}let c;u.includes("#")?(c=u.split("#"),n("使用#号分隔填空答案","green")):u.includes(",")||u.includes(",")?(c=u.split(/[,,]/),n("使用逗号分隔填空答案","green")):u.includes(" ")||u.includes(" ")?(c=u.split(/[\s\t]+/),n("使用空格分隔填空答案","green")):u.includes(";")||u.includes(";")?(c=u.split(/[;;]/),n("使用分号分隔填空答案","green")):(c=[u],n("填空答案无分隔符,作为单个答案处理","green"));let p=i(t[e]).find(".blankList2 input");i.each(p,(y,k)=>{if(y{i(k).val(v)},200)}}),n("填空题自动答题成功,准备切换下一题","green"),setTimeout(()=>{A(e+1,t)},setting.time)}).catch(l=>{l.c==0&&setTimeout(()=>{A(e+1,t)},setting.time)});break;case 3:n("判断题(只回答正确或错误): "+r,"blue"),_(o,r).then(l=>{if(!l||l.trim()===""||l.includes("未找到答案")||l==="暂无答案"){n("未获取到有效答案,跳过此题","red"),localStorage.setItem("GPTJsSetting.sub",!1),setTimeout(()=>{A(e+1,t)},setting.time);return}let u="正确|是|对|√|T|ri|true|yes",c="错误|否|错|×|F|wr|false|no";d=i(t[e]).find(".answerList.panduan li");let p=l;l.includes("答案:")&&(p=l.split("答案:")[1].trim().split(/[\n\r]/)[0].trim(),n("从AI回答中提取判断结果: "+p,"green"));let y=!1,k=!1;u.split("|").forEach(v=>{p.toLowerCase().includes(v.toLowerCase())&&(y=!0)}),c.split("|").forEach(v=>{p.toLowerCase().includes(v.toLowerCase())&&(k=!0)}),y&&!k?(n('判断为"正确"',"green"),i.each(d,(v,w)=>{i(w).attr("val-param")=="true"&&i(w).click()})):k&&!y?(n('判断为"错误"',"green"),i.each(d,(v,w)=>{i(w).attr("val-param")=="false"&&i(w).click()})):u.indexOf(p)!=-1?(n('使用原有逻辑判断为"正确"',"green"),i.each(d,(v,w)=>{i(w).attr("val-param")=="true"&&i(w).click()})):(n('默认判断为"错误"',"orange"),i.each(d,(v,w)=>{i(w).attr("val-param")=="false"&&i(w).click()})),n("自动答题成功,准备切换下一题","green"),setTimeout(()=>{A(e+1,t)},setting.time)}).catch(l=>{l.c==0&&setTimeout(()=>{A(e+1,t)},setting.time)});break;case 4:n("判断题(只回答正确或错误): "+r,"blue"),_(o,r).then(l=>{if(!l||l.trim()===""||l.includes("未找到答案")||l==="暂无答案"){n("未获取到有效答案,跳过此题","red"),localStorage.setItem("GPTJsSetting.sub",!1),setTimeout(()=>{A(e+1,t)},setting.time);return}let u="正确|是|对|√|T|ri|true|yes",c="错误|否|错|×|F|wr|false|no";d=i(t[e]).find(".answerList.panduan li");let p=l;l.includes("答案:")&&(p=l.split("答案:")[1].trim().split(/[\n\r]/)[0].trim(),n("从AI回答中提取判断结果: "+p,"green"));let y=!1,k=!1;u.split("|").forEach(v=>{p.toLowerCase().includes(v.toLowerCase())&&(y=!0)}),c.split("|").forEach(v=>{p.toLowerCase().includes(v.toLowerCase())&&(k=!0)}),y&&!k?(n('判断为"正确"',"green"),i.each(d,(v,w)=>{i(w).attr("val-param")=="true"&&i(w).click()})):k&&!y?(n('判断为"错误"',"green"),i.each(d,(v,w)=>{i(w).attr("val-param")=="false"&&i(w).click()})):u.indexOf(p)!=-1?(n('使用原有逻辑判断为"正确"',"green"),i.each(d,(v,w)=>{i(w).attr("val-param")=="true"&&i(w).click()})):(n('默认判断为"错误"',"orange"),i.each(d,(v,w)=>{i(w).attr("val-param")=="false"&&i(w).click()})),n("自动答题成功,准备切换下一题","green"),setTimeout(()=>{A(e+1,t)},setting.time)}).catch(l=>{l.c==0&&setTimeout(()=>{A(e+1,t)},setting.time)});break;case 5:_(o,r).then(l=>{localStorage.setItem("GPTJsSetting.sub",!1),n("此类型题目无法区分单/多选,请手动选择答案","red"),setTimeout(()=>{A(e+1,t)},setting.time)}).catch(l=>{l.c==0&&setTimeout(()=>{A(e+1,t)},setting.time)});break;default:n("暂不支持处理此类型题目:"+s.match(/.*?\[(.*?)]|$/)[1]+",跳过!请手动作答。","red"),localStorage.setItem("GPTJsSetting.sub",!1),setTimeout(()=>{A(e+1,t)},setting.time);break}}function ee(e,t,s){if(e==t.length){n("此页面全部测验已处理完毕!准备进行下一项任务"),setTimeout(te,5e3);return}n("等待测验框架加载...","purple"),se(i(t[e]).contents()[0],"iframe").then(r=>{let o=r;o.length==0&&setTimeout(()=>{ee(e,t)},5e3);let a=i(o).contents().find(".newTestCon .newTestTitle .testTit_status").text().trim();if(!a){E.splice(0,1),setTimeout(te,2e3);return}setting.share&&a.indexOf("已完成")!=-1?(n("测验:"+(e+1)+",检测到此测验已完成,准备收录答案。","green"),setTimeout(()=>{xe(e,t,o)},2e3)):a.indexOf("待做")!=-1||a.indexOf("待完成")!=-1||a.indexOf("未达到及格线")!=-1?(n("测验:"+(e+1)+",准备处理此测验...","purple"),i(o).attr("src",s),se(i(t[e]).contents()[0],'iframe[src="'+s+'"]').then(d=>{setTimeout(()=>{De(i(d).contents())},3e3)})):a.indexOf("待批阅")!=-1?(S.splice(0,1),E.splice(0,1),n("测验:"+(e+1)+",测验待批阅,跳过","red"),setTimeout(()=>{ee(e+1,t,s)},5e3)):(S.splice(0,1),E.splice(0,1),n("测验:"+(e+1)+",未知状态或用户选择不收录答案,跳过","red"),setTimeout(()=>{ee(e+1,t,s)},5e3))})}function N(e,t){if(e==t.length){n("此页面全部测验已处理完毕!准备进行下一项任务"),setTimeout(te,5e3);return}n("等待测验框架加载...","purple"),se(i(t[e]).contents()[0],"iframe").then(s=>{let r=s;r.length==0&&setTimeout(()=>{N(e,t)},5e3);let o=i(r).contents().find(".newTestCon .newTestTitle .testTit_status").text().trim();if(!o){E.splice(0,1),setTimeout(te,2e3);return}setting.share&&o.indexOf("已完成")!=-1?(n("测验:"+(e+1)+",检测到此测验已完成,准备收录答案。","green"),setTimeout(()=>{xe(e,t,r)},2e3)):o.indexOf("待做")!=-1||o.indexOf("待完成")!=-1?(n("测验:"+(e+1)+",准备处理此测验...","purple"),setTimeout(()=>{Ne(e,t,r)},5e3)):o.indexOf("待批阅")!=-1?(S.splice(0,1),E.splice(0,1),n("测验:"+(e+1)+",测验待批阅,跳过","red"),setTimeout(()=>{N(e+1,t)},5e3)):(S.splice(0,1),E.splice(0,1),n("测验:"+(e+1)+",未知状态或用户选择不收录答案,跳过","red"),setTimeout(()=>{N(e+1,t)},5e3))})}function se(e,t,s=0){return new Promise(r=>{let o=e.querySelector(t);if(o)return r(o);let a;const d=window.MutationObserver||window.WebkitMutationObserver||window.MozMutationObserver;if(d){const f=new d(g=>{for(let m of g)for(let b of m.addedNodes)if(b instanceof Element&&(o=b.matches(t)?b:b.querySelector(t),o))return f.disconnect(),a&&clearTimeout(a),r(o)});f.observe(e,{childList:!0,subtree:!0}),s>0&&(a=setTimeout(()=>(f.disconnect(),r(null)),s))}else{const f=g=>{if(g.target instanceof Element&&(o=g.target.matches(t)?g.target:g.target.querySelector(t),o))return e.removeEventListener("DOMNodeInserted",f,!0),a&&clearTimeout(a),r(o)};e.addEventListener("DOMNodeInserted",f,!0),s>0&&(a=setTimeout(()=>(e.removeEventListener("DOMNodeInserted",f,!0),r(null)),s))}})}function Fe(){n("开始处理作业","green");let t=i(".mark_table").find("form").find(".questionLi");C(0,t)}function C(e,t){if(e==t.length){n("作业题目已全部完成","green");return}let s={单选题:0,多选题:1,填空题:2,判断题:3,简答题:4,写作题:5,翻译题:6}[i(t[e]).attr("typename")],r=i(t[e]).find(".mark_name").html(),o=K(r).replace(/^[(].*?[)]/,"").trim(),a=[],d,f;var g=0;switch(s){case 0:d=i(t[e]).find(".stem_answer").find(".answer_p");var b=[];d.each(function(){var c=i(this).text().replace(/[ABCD]/g,"").trim();b.push(c)}),b=b.join("|"),o="单选题:"+o+` `+b;for(var m=0;m{C(e+1,t)},300);break}g==0&&_(s,o).then(c=>{i.each(d,(y,k)=>{a.push(P(i(k).html()))});let p=a.findIndex(y=>y==c);if(localStorage.getItem("GPTJsSetting.alterTitle")==="true"){let y=i(t[e]).find(".mark_name");y.html(y.html()+"

"+c)}p==-1?(n("AI无法完美匹配正确答案,请手动选择,跳过此题","red"),setTimeout(()=>{C(e+1,t)},setting.time)):setTimeout(()=>{i(d[p]).parent().find("span").attr("class").indexOf("check_answer")==-1&&i(d[p]).parent().click(),n("自动答题成功,准备切换下一题","green"),setTimeout(()=>{C(e+1,t)},setting.time)},300)}).catch(c=>{c.c==0&&setTimeout(()=>{C(e+1,t)},setting.time)});break;case 1:d=i(t[e]).find(".stem_answer").find(".answer_p");var b=[];d.each(function(){var c=i(this).text().replace(/[ABCD]/g,"").trim();b.push(c)}),b=b.join("|"),o="多选题:"+o+` `+b;for(var m=0;m{C(e+1,t)},300);break}g==0&&_(s,o).then(c=>{if(localStorage.getItem("GPTJsSetting.alterTitle")==="true"){let p=i(t[e]).find(".mark_name");p.html(p.html()+"

"+c)}i.each(d,(p,y)=>{c.indexOf(P(i(y).html()))!=-1&&setTimeout(()=>{i(d[p]).parent().find("span").attr("class").indexOf("check_answer_dx")==-1&&i(d[p]).parent().click()},300)}),n("自动答题成功,准备切换下一题","green"),setTimeout(()=>{C(e+1,t)},setting.time)}).catch(c=>{c.c==0&&setTimeout(()=>{C(e+1,t)},setting.time)});break;case 2:o='填空题,用"|"分割多个答案:'+o,f=i(t[e]).find(".stem_answer").find(".Answer .divText .textDIV textarea");let x=i(f).attr("id");D.getEditor(x).getContent()!==""?(n(e+1+"此题已作答,准备切换下一题","green"),setTimeout(()=>{C(e+1,t)},300)):_(s,o).then(c=>{i.each(f,(p,y)=>{let k=i(y).attr("id");if(D.getEditor(k).getContent()===""){let v=c.split("|");setTimeout(()=>{D.getEditor(k).setContent(v[p])},300)}}),setTimeout(()=>{C(e+1,t)},setting.time),n("自动答题成功,准备切换下一题","green")});break;case 3:let h="正确|是|对|√|T|ri",l="错误|否|错|×|F|wr",u=0;d=i(t[e]).find(".stem_answer").find(".answer_p"),o="判断题(只回答正确或错误):"+o+` `+d.text(),i.each(d,(c,p)=>{a.push(i(p).text().trim())});for(var m=0;m{C(e+1,t)},300);break}g==0&&_(s,o).then(c=>{if(h.indexOf(c)!=-1)u=a.findIndex(p=>h.indexOf(p)!=-1);else if(l.indexOf(c)!=-1)u=a.findIndex(p=>l.indexOf(p)!=-1);else{n("答案匹配出错,准备切换下一题","green"),setTimeout(()=>{C(e+1,t)},setting.time);return}setTimeout(()=>{i(d[u]).parent().find("span").attr("class").indexOf("check_answer")==-1&&i(d[u]).parent().click()},300),n("自动答题成功,准备切换下一题","green"),setTimeout(()=>{C(e+1,t)},setting.time)}).catch(c=>{c.c==0&&setTimeout(()=>{C(e+1,t)},setting.time)});break;case 4:o="用50字简要回答:"+o,f=i(t[e]).find(".stem_answer").find(".eidtDiv textarea"),i.each(f,(c,p)=>{let y=i(p).attr("id");D.getEditor(y).getContent()!==""?(n(e+1+"此题已作答,准备切换下一题","green"),setTimeout(()=>{C(e+1,t)},300)):_(s,o).then(k=>{setTimeout(()=>{D.getEditor(y).setContent(k)},300),n("自动答题成功,准备切换下一题","green"),setTimeout(()=>{C(e+1,t)},setting.time)}).catch(k=>{k.c==0&&setTimeout(()=>{C(e+1,t)},setting.time)})});break;case 5:_answerEle=$_ansdom.find(".subEditor textarea"),jdt="用英文根据题目进行写作:"+o,i.each(_answerEle,(c,p)=>{_(_qType,jdt).then(y=>{let k=i(p).attr("name");setTimeout(()=>{D.getEditor(k).setContent(y)},300)})});break;case 6:_answerEle=$_ansdom.find(".subEditor textarea"),jdt="中文英文翻译题:"+o,i.each(_answerEle,(c,p)=>{_(_qType,jdt).then(y=>{let k=i(p).attr("name");setTimeout(()=>{D.getEditor(k).setContent(y)},300)})});break;default:_answerEle=$_ansdom.find(".subEditor textarea"),_answerEle!==null?(jdt=i(t[e]).attr("typename")+":"+o,i.each(_answerEle,(c,p)=>{_(_qType,jdt).then(y=>{let k=i(p).attr("name");setTimeout(()=>{D.getEditor(k).setContent(y)},300)})})):(n("暂不支持处理此题型:"+i(t[e]).attr("typename")+",跳过。","red"),setTimeout(()=>{C(e+1,t)},setting.time))}}function $e(){let e=i(".mark_table").find(".whiteDiv"),t=P(e.find("h3.mark_name").html().trim()),s={单选题:0,多选题:1,填空题:2,判断题:3,简答题:4,论述题:4,写作题:5,翻译题:6}[t.match(/[(](.*?),.*?分[)]|$/)[1]],r=K(t.replace(/[(].*?分[)]/,"").replace(/^\s*/,"")),o=e.find("#submitTest").find(".stem_answer"),a,d=[];switch(s){case 0:a=o.find(".clearfix.answerBg .fl.answer_p");var f=[];a.each(function(){var h=i(this).text().replace(/[ABCD]/g,"").trim();f.push(h)}),f=f.join("|"),r="单选题:"+r+` `+f,r=K(r.replace(/[(].*?分[)]/,"").replace(/^\s*/,"")),_(s,r).then(h=>{if(i.each(a,(u,c)=>{d.push(P(i(c).html()))}),localStorage.getItem("GPTJsSetting.alterTitle")==="true"){let u=e.find("h3.mark_name");u.html(u.html()+h)}let l=d.findIndex(u=>u==h);l==-1?(n("AI无法完美匹配正确答案,请手动选择,跳过此题","red"),setTimeout(B,5e3)):setTimeout(()=>{i(a[l]).parent().find("span").attr("class").indexOf("check_answer")==-1?(localStorage.getItem("GPTJsSetting.goodStudent")==="true"?i(a[l]).parent().find("span").css("font-weight","bold"):setTimeout(()=>{i(a[l]).parent().click()},300),n("自动答题成功,准备切换下一题","green"),B()):(n(index+1+"此题已作答,准备切换下一题","green"),B())},300)}).catch(h=>{h.c==0&&B()});break;case 1:a=o.find(".clearfix.answerBg .fl.answer_p");var f=[];a.each(function(){var h=i(this).text().replace(/[ABCD]/g,"").trim();f.push(h)}),f=f.join("|"),r="多选题:"+r+` `+f,_(s,r).then(h=>{if(localStorage.getItem("GPTJsSetting.alterTitle")==="true"){let l=e.find("h3.mark_name");l.html(l.html()+h)}o.find(".clearfix.answerBg span.check_answer_dx").length>0?(n(index+1+"此题已作答,准备切换下一题","green"),B()):(i.each(a,(l,u)=>{h.indexOf(P(i(u).html()))!=-1&&(localStorage.getItem("GPTJsSetting.goodStudent")==="true"?i(a[x]).parent().find("span").css("font-weight","bold"):setTimeout(()=>{i(a[l]).parent().click()},300))}),n("自动答题成功,准备切换下一题","green"),B())}).catch(h=>{h.c==0&&B()});break;case 2:r='填空题,用"|"分割多个答案:'+r;let g=o.find(".Answer .divText .subEditor textarea");_(s,r).then(h=>{let l=h.split("|");i.each(g,(u,c)=>{let p=i(c).attr("id");setTimeout(()=>{D.getEditor(p).setContent(l[u])},300)}),n("自动答题成功,准备切换下一题","green"),B()});break;case 3:let m="正确|是|对|√|T|ri",b="错误|否|错|×|F|wr",x=0;r="判断题(只回答正确或错误):"+r,a=o.find(".clearfix.answerBg .fl.answer_p"),i.each(a,(h,l)=>{d.push(i(l).text().trim())}),_(s,r).then(h=>{if(localStorage.getItem("GPTJsSetting.alterTitle")==="true"){let l=e.find("h3.mark_name");l.html(l.html()+h)}if(m.indexOf(h)!=-1)x=d.findIndex(l=>m.indexOf(l)!=-1);else if(b.indexOf(h)!=-1)x=d.findIndex(l=>b.indexOf(l)!=-1);else{n("答案匹配出错,准备切换下一题","green"),B();return}i(a[x]).parent().find("span").attr("class").indexOf("check_answer")==-1?(localStorage.getItem("GPTJsSetting.goodStudent")==="true"?setTimeout(()=>{i(a[x]).parent().find("span").css("font-weight","bold")},300):i(a[x]).parent().click(),n("自动答题成功,准备切换下一题","green"),B()):(n(index+1+"此题已作答,准备切换下一题","green"),B())}).catch(h=>{h.c==0&&B()});break;case 4:_answerEle=o.find(".subEditor textarea"),jdt="用50字简要回答:"+r,i.each(_answerEle,(h,l)=>{_(s,jdt).then(u=>{let c=i(l).attr("name");setTimeout(()=>{D.getEditor(c).setContent(u)},300),B()})});break;case 5:_answerEle=o.find(".subEditor textarea"),jdt="用英文根据题目进行写作:"+r,i.each(_answerEle,(h,l)=>{_(s,jdt).then(u=>{let c=i(l).attr("name");setTimeout(()=>{D.getEditor(c).setContent(u)},300),B()})});break;case 6:_answerEle=o.find(".subEditor textarea"),jdt="中文英文翻译题:"+r,i.each(_answerEle,(h,l)=>{_(s,jdt).then(u=>{let c=i(l).attr("name");setTimeout(()=>{D.getEditor(c).setContent(u)},300),B()})});break;default:_answerEle=o.find(".Answer .divText .subEditor textarea"),typeof _answerEle<"u"?(jdt=t.match(/[(](.*?),.*?分[)]|$/)[1]+':填空题,用"|"分割多个答案:'+r,_(s,r).then(h=>{let l=h.split("|");i.each(_answerEle,(u,c)=>{let p=i(c).attr("id");setTimeout(()=>{D.getEditor(p).setContent(l[u])},300)}),n("自动答题成功,准备切换下一题","green"),B()})):(n("暂不支持处理此题型:"+i(TiMuList[index]).attr("typename")+",跳过。","red"),setTimeout(()=>{C(index+1,TiMuList)},setting.time))}}function B(){if(localStorage.getItem("GPTJsSetting.examTurn")==="true"){let t=i(".mark_table").find(".whiteDiv").find(".nextDiv a.jb_btn");setTimeout(()=>{t.click()},setting.examTurnTime?2e3+Math.floor(Math.random()*5+1)*1e3:2e3)}else n("用户设置不自动跳转下一题,请手动点击","blue")}function qe(){n("考试答案收录功能处于bate阶段,遇到bug请及时反馈!!","red"),n("考试答案收录功能处于bate阶段,遇到bug请及时反馈!!","red"),n("开始收录考试答案","green");let e=i(".mark_table .mark_item .questionLi"),t=[];i.each(e,(s,r)=>{let o={},a,d,f=[],g=K(i(r).find("h3").html()),m={单选题:0,多选题:1,填空题:2,判断题:3,简答题:4}[g.match(/[(](.*?)[)]|$/)[1].replace(/,.*?分/,"")],b=g.replace(/^[(].*?[)]|$/,"").trim(),x=i(r).find(".mark_answer").find(".colorGreen").text().replace(/正确答案[::]/,"").trim();switch(m){case 0:if(x.length<=0)if(_isTrue=i(r).find(".mark_answer").find(".mark_score span").attr("class"),_isZero=i(r).find(".mark_answer").find(".mark_score .totalScore.fr i").text(),_isTrue=="marking_dui"||_isZero!="0")x=i(r).find(".mark_answer").find(".colorDeep").text().replace(/我的答案[::]/,"").trim();else break;d=i(r).find(".mark_letter li"),i.each(d,(u,c)=>{f.push(P(i(c).html()).replace(/[A-Z].\s*/,""))});let h={A:0,B:1,C:2,D:3,E:4,F:5,G:6}[x];a=f[h],o.question=b,o.type=m,o.answer=a,t.push(o);break;case 1:if(a=[],x.length<=0)if(_isTrue=i(r).find(".mark_answer").find(".mark_score span").attr("class"),_isZero=i(r).find(".mark_answer").find(".mark_score .totalScore.fr i").text(),_isTrue=="marking_dui"||_isTrue=="marking_bandui"||_isZero!="0")x=i(r).find(".mark_answer").find(".colorDeep").text().replace(/我的答案[::]/,"").trim();else break;d=i(r).find(".mark_letter li"),i.each(d,(u,c)=>{f.push(P(i(c).html()).replace(/[A-Z].\s*/,""))}),i.each(x.split(""),(u,c)=>{let p={A:0,B:1,C:2,D:3,E:4,F:5,G:6}[c];a.push(f[p])}),o.question=b,o.type=m,o.answer=a.join("#"),t.push(o);break;case 2:d=[];let l=i(r).find(".mark_answer").find(".colorDeep").find("dd");x.length<=0?(i.each(l,(u,c)=>{if(_isTrue=i(c).find("span:eq(1)").attr("class"),_isTrue=="marking_dui")x=i(c).find("span:eq(0)").html(),d.push(x.replace(/[(][0-9].*?[)]/,"").replace(/第.*?空:/,"").trim());else return}),a=d.join("#")):a=x.replace(/\s/g,"").replace(/[(][0-9].*?[)]/g,"#").replace(/第.*?空:/g,"#").replace(/^#*/,""),a.length!=0&&(o.question=b,o.type=m,o.answer=a,t.push(o));break;case 3:if(x.length<=0)if(_isTrue=i(r).find(".mark_answer").find(".mark_score span").attr("class"),_isZero=i(r).find(".mark_answer").find(".mark_score .totalScore.fr i").text(),_isTrue=="marking_dui"||_isZero!="0")x=i(r).find(".mark_answer").find(".colorDeep").text().replace(/我的答案[::]/,"").trim();else{let u="正确|是|对|√|T|ri";x=i(r).find(".mark_answer").find(".colorDeep").text().replace(/我的答案[::]/,"").trim(),u.indexOf(x)!=-1?x="错":x="对"}o.question=b,o.type=m,o.answer=x,t.push(o);break;case 4:if(x.length<=0)break;o.question=b,o.type=m,o.answer=x,t.push(o);break}}),setTimeout(()=>{fe(t)},1500)}function je(){let e=Ie();return new Promise((t,s)=>{i.ajax({url:I.protocol+"//"+I.host+"/mycourse/studentstudycourselist?courseId="+e.courseid+"&chapterId="+e.knowledgeid+"&clazzid="+e.clazzid+"&mooc2=1",type:"GET",dateType:"html",success:function(r){t(r)}})})}function he(e,t,s,r,o,a,d,f,g,m,b,x){return new Promise((h,l)=>{(void 0).then(u=>{pe&&(e=_e(e)),i.ajax({url:e+"/"+t+"?clazzId="+s+"&playingTime="+r+"&duration="+o+"&clipTime="+a+"&objectId="+d+"&otherInfo="+f+"&jobid="+g+"&userid="+m+"&isdrag="+b+"&view=pc&enc="+u+"&rt="+Number(x)+"&dtype=Audio&_t="+String(Math.round(new Date)),type:"GET",success:function(c){try{c.isPassed?setting.review&&r!=o?h(1):h(2):setting.rate==0&&r==o?h(2):h(1)}catch(p){n("发生错误:"+p,"red"),h(0)}},error:function(c){c.status==403?(n("超星返回错误信息,尝试更换参数,40s后将重试,请等待...","red"),h(3)):(pe=1,n("超星返回错误信息,如果持续出现,请联系作者","red"))}})})})}function xe(e,t,s){let o=i(s).contents().find(".CeYan").find(".TiMu"),a=[];for(let d=0;d div.clearfix").html().trim(),m=K(g),b={单选题:0,多选题:1,填空题:2,判断题:3,简答题:4}[g.match(/^【(.*?)】|$/)[1]];f.question=m,f.type=b;let x=i(o[d]).find(".Py_answer.clearfix > i").attr("class");switch(b){case 0:if(x=="fr dui"){let y={A:0,B:1,C:2,D:3,E:4,F:5,G:6}[i(o[d]).find(".Py_answer.clearfix > span").html().trim().replace(/正确答案[::]/,"").replace(/我的答案[::]/,"").trim()],k=i(o[d]).find(".Zy_ulTop li"),v=i(k[y]).find("a.fl").html();f.answer=P(v)}break;case 1:let h=i(o[d]).find(".Py_answer.clearfix > span").html().trim().replace(/正确答案[::]/,"").replace(/我的答案[::]/,"").trim(),l=i(o[d]).find(".Zy_ulTop li"),u=[];if(x=="fr dui"||x=="fr bandui")for(let y=0;y span > i").html().replace(/正确答案[::]/,"").replace(/我的答案[::]/,"").trim();f.answer=P(y)}else if(i(o[d]).find(".Py_answer.clearfix > span > i").html()){let y=i(o[d]).find(".Py_answer.clearfix > span > i").html().replace(/正确答案[::]/,"").replace(/我的答案[::]/,"").trim();f.answer=P(y)=="√"?"x":"√"}else break;break}if(f.answer!=null)a.push(f);else continue}fe(a).then(()=>{S.splice(0,1),E.splice(0,1),setTimeout(()=>{N(e+1,t)},3e3)})}function Ke(){n("开始收录答案","green");let t=i(".mark_table").find(".mark_item").find(".questionLi"),s=[];i.each(t,(r,o)=>{let a={},d,f,g=[],m=K(i(o).find("h3.mark_name").html()),b={单选题:0,多选题:1,填空题:2,判断题:3,简答题:4}[m.match(/[(](.*?)[)]|$/)[1].replace(/, .*?分/,"")],x=m.replace(/^[(].*?[)]|$/,"").trim(),h=i(o).find(".mark_answer").find(".colorGreen").text().replace(/正确答案[::]/,"").trim();switch(b){case 0:if(h.length<=0)if(_isTrue=i(o).find(".mark_answer").find(".mark_score span").attr("class"),_isZero=i(o).find(".mark_answer").find(".mark_score .totalScore.fr i").text(),_isTrue=="marking_dui"||_isZero!="0")h=i(o).find(".mark_answer").find(".colorDeep").text().replace(/我的答案[::]/,"").trim();else return;f=i(o).find(".mark_letter li"),i.each(f,(c,p)=>{g.push(P(i(p).html()).replace(/[A-Z].\s*/,""))});let l={A:0,B:1,C:2,D:3,E:4,F:5,G:6}[h];d=g[l],a.question=x,a.type=b,a.answer=d,s.push(a);break;case 1:if(d=[],h.length<=0)if(_isTrue=i(o).find(".mark_answer").find(".mark_score span").attr("class"),_isZero=i(o).find(".mark_answer").find(".mark_score .totalScore.fr i").text(),_isTrue=="marking_dui"||_isTrue=="marking_bandui"||_isZero!="0")h=i(o).find(".mark_answer").find(".colorDeep").text().replace(/我的答案[::]/,"").trim();else break;f=i(o).find(".mark_letter li"),i.each(f,(c,p)=>{g.push(P(i(p).html()).replace(/[A-Z].\s*/,""))}),i.each(h.split(""),(c,p)=>{let y={A:0,B:1,C:2,D:3,E:4,F:5,G:6}[p];d.push(g[y])}),a.question=x,a.type=b,a.answer=d.join("#"),s.push(a);break;case 2:f=[];let u=i(o).find(".mark_answer").find(".colorDeep").find("dd");h.length<=0?(i.each(u,(c,p)=>{if(_isTrue=i(p).find("span:eq(1)").attr("class"),_isTrue=="marking_dui")h=i(p).find("span:eq(0)").html(),f.push(h.replace(/[(][0-9].*?[)]/,"").replace(/第.*?空:/,"").trim());else return}),d=f.join("#")):d=h.replace(/\s/g,"").replace(/[(][0-9].*?[)]/g,"#").replace(/第.*?空:/g,"#").replace(/^#*/,""),d.length!=0&&(a.question=x,a.type=b,a.answer=d,s.push(a));break;case 3:if(h.length<=0)if(_isTrue=i(o).find(".mark_answer").find(".mark_score span").attr("class"),_isZero=i(o).find(".mark_answer").find(".mark_score .totalScore.fr i").text(),_isTrue=="marking_dui"||_isZero!="0")h=i(o).find(".mark_answer").find(".colorDeep").text().replace(/我的答案[::]/,"").trim();else{let c="正确|是|对|√|T|ri";h=i(o).find(".mark_answer").find(".colorDeep").text().replace(/我的答案[::]/,"").trim(),c.indexOf(h)!=-1?h="错":h="对"}a.question=x,a.type=b,a.answer=h,s.push(a);break;case 4:if(h.length<=0)break;a.question=x,a.type=b,a.answer=h,s.push(a);break}}),setTimeout(()=>{fe(s)},1500)}function _(e,t){return n("题目:"+t,"pink"),new Promise((s,r)=>{let o=t,a=e;t.startsWith("单选题:")?(a="0",o=t.substring(4),n("从题目中提取题型: 单选题","blue")):t.startsWith("多选题:")?(a="1",o=t.substring(4),n("从题目中提取题型: 多选题","blue")):t.startsWith("判断题:")&&(a="3",o=t.substring(4),n("从题目中提取题型: 判断题","blue"));let d=localStorage.getItem("GPTJsSetting.key")||localStorage.getItem("tiku_key")||"";if(!d){n("未配置Key,请在设置中配置您的Key","red"),r("请在设置中配置您的Key");return}if(localStorage.getItem("GPTJsSetting.useTiku")!=="true"){n("题库答题功能已关闭,跳过题库查询","orange"),n("题库答题功能状态:"+(localStorage.getItem("GPTJsSetting.useTiku")==="true"?"已开启":"未开启"),"#1890ff"),n("AI答题功能状态:"+(localStorage.getItem("GPTJsSetting.useAI")==="true"?"已开启":"未开启"),"#1890ff"),n("随机答题功能状态:"+(localStorage.getItem("GPTJsSetting.randomAnswer")==="true"?"已开启":"未开启"),"#1890ff"),n("使用模型:"+(localStorage.getItem("GPTJsSetting.model")||"gpt-3.5-turbo-16k"),"#1890ff");let u={0:"单选题",1:"多选题",2:"填空题",3:"判断题",4:"简答题",5:"选择题"}[a]||"未知题型";if(n("题目类型: "+u,"#1890ff"),localStorage.getItem("GPTJsSetting.useAI")==="true"){n("已开启AI答题功能,准备获取AI答案...","#1890ff"),n("传递给AI的题型: "+u,"#1890ff");let c=setTimeout(()=>{if(n("AI答题系统响应超时,切换到随机答题...","red"),localStorage.getItem("GPTJsSetting.randomAnswer")==="true"){n("尝试使用随机答题功能作为备选...","#1890ff");const p=Z(u);n("成功生成随机答案: "+p,"green"),s(p)}else localStorage.setItem("GPTJsSetting.sub",!1),s("")},3e4);ie(o,u).then(p=>{clearTimeout(c),n("AI成功回答,继续处理...","green"),s(p)}).catch(p=>{if(clearTimeout(c),n("AI回答失败: "+p,"red"),localStorage.getItem("GPTJsSetting.randomAnswer")==="true"){n("尝试使用随机答题功能作为备选...","#1890ff");const y=Z(u);n("成功生成随机答案: "+y,"green"),s(y)}else localStorage.setItem("GPTJsSetting.sub",!1),s("")});return}if(localStorage.getItem("GPTJsSetting.randomAnswer")==="true"){n("已开启随机答题功能,准备生成随机答案...","#1890ff");const c=Z(u);n("成功生成随机答案: "+c,"green"),s(c);return}n("未开启AI答题和随机答题功能,留空并继续下一题...","red"),localStorage.setItem("GPTJsSetting.sub",!1),s("");return}let f="";try{const l=[".option-content",".el-radio__label",".el-checkbox__label",".ant-radio-wrapper",".ant-checkbox-wrapper","label.option",".option-item",".answer-item",".subject-item","li.option",'div[class*="option"]','span[class*="option"]','input[type="radio"] + label','input[type="checkbox"] + label'],u=document.querySelectorAll(l.join(", "));if(u&&u.length>0){const c=[];if(u.forEach(p=>{let y=p.textContent.trim();y=y.replace(/^[A-Z][\.\、\s]+/i,"").trim(),y&&!c.includes(y)&&c.push(y)}),c.length===0){const p=t.match(/\(([^)]+)\)/);if(p&&p[1])c.push(...p[1].split(/[,,、|]/));else{const y=t.match(/[A-D][\.、][\s\S]+?[A-D][\.、][\s\S]+/);y&&c.push(...y[0].split(/[A-D][\.、]/));const k=t.split(/[|,,、]/);k.length>1&&k[k.length-1].match(/[A-D]/)&&c.push(...k)}}f=c.join("|"),n("提取到选项: "+f,"blue")}}catch(l){n("提取选项失败: "+l,"red")}let g="";const m=o.lastIndexOf(" ");if(m!==-1){const l=o.substring(m+1);l.includes("|")&&(o=o.substring(0,m),g=l,n("从题目中提取选项: "+g,"blue"))}if(!g){const l=o.match(/\(\)[\s]*([^()]+)$/);if(l&&l[1]){const u=l[1].trim();u.includes("|")&&(g=u,o=o.replace(/\(\)[\s]*[^()]+$/,"()"),n("从题目括号后提取选项: "+g,"blue"))}}n("处理后的题目: "+o,"green");let x={0:"单选题",1:"多选题",2:"填空题",3:"判断题",4:"简答题",5:"选择题"}[a]||"未知题型";n("题目类型: "+x,"green"),g?n("使用题目中提取的选项: "+g,"green"):f&&n("使用页面元素提取的选项: "+f,"green");let h="key="+encodeURIComponent(d)+"&question="+encodeURIComponent(o)+"&type="+encodeURIComponent(a);g?h+="&options="+encodeURIComponent(g):f&&(h+="&options="+encodeURIComponent(f)),GM_xmlhttpRequest({method:"POST",url:API_BASE_URL+"?act=xxt",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:h,timeout:1e4,onload:function(l){if(l.status==200)try{let u=JSON.parse(l.responseText);if(u.code===0){if(n("错误: "+u.msg,"red"),u.msg.includes("Key验证失败")||u.msg.includes("请提供有效的Key")){n("请在设置中配置正确的Key","red"),J("Key验证失败","请检查您的Key是否正确,并在设置中重新配置","");const c=document.createElement("div");c.textContent="Key验证失败,请检查您的Key是否正确",c.style.cssText=` position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: #F56C6C; color: white; padding: 10px 20px; border-radius: 4px; box-shadow: 0 2px 12px 0 rgba(0,0,0,0.1); z-index: 10000; transition: all 0.3s; `,document.body.appendChild(c),setTimeout(()=>{c.style.opacity="0",setTimeout(()=>{document.body.removeChild(c)},500)},3e3),r(u.msg);return}if(u.msg.includes("未找到答案")){n("暂无答案,准备使用AI尝试回答...","orange"),n("题库答题功能状态:"+(localStorage.getItem("GPTJsSetting.useTiku")==="true"?"已开启":"未开启"),"#1890ff"),n("AI答题功能状态:"+(localStorage.getItem("GPTJsSetting.useAI")==="true"?"已开启":"未开启"),"#1890ff"),n("随机答题功能状态:"+(localStorage.getItem("GPTJsSetting.randomAnswer")==="true"?"已开启":"未开启"),"#1890ff"),n("使用模型:"+(localStorage.getItem("GPTJsSetting.model")||"gpt-3.5-turbo-16k"),"#1890ff"),J("暂无答案",`题型: ${x} 题目: ${o.substring(0,30)}...`,"");const c=document.createElement("div");if(c.textContent="暂无答案,尝试使用AI...",c.style.cssText=` position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: #E6A23C; color: white; padding: 10px 20px; border-radius: 4px; box-shadow: 0 2px 12px 0 rgba(0,0,0,0.1); z-index: 10000; transition: all 0.3s; `,document.body.appendChild(c),setTimeout(()=>{c.style.opacity="0",setTimeout(()=>{document.body.removeChild(c)},500)},3e3),localStorage.getItem("GPTJsSetting.useAI")==="true"){n("已开启AI答题功能,准备获取AI答案...","#1890ff"),ie(o,x).then(p=>{n("AI成功回答,继续处理...","green"),s(p)}).catch(p=>{if(n("AI回答失败: "+p,"red"),localStorage.getItem("GPTJsSetting.randomAnswer")==="true"){n("尝试使用随机答题功能作为备选...","#1890ff");const y=Z(x);n("成功生成随机答案: "+y,"green"),s(y)}else localStorage.setItem("GPTJsSetting.sub",!1),s("")});return}if(localStorage.getItem("GPTJsSetting.randomAnswer")==="true"){n("已开启随机答题功能,准备生成随机答案...","#1890ff");const p=Z(x);n("成功生成随机答案: "+p,"green"),s(p);return}n("未开启AI答题和随机答题功能,留空并继续下一题...","red"),localStorage.setItem("GPTJsSetting.sub",!1),s("")}r(u.msg);return}if((u.code==200||u.code==1e3)&&u.data&&u.data.answer&&u.data.answer.trim()!=="")n("答案:"+u.data.answer,"pink"),s(u.data.answer);else{n("暂无答案,准备使用AI尝试回答...","orange"),n("AI答题功能状态:"+(localStorage.getItem("GPTJsSetting.useAI")==="true"?"已开启":"未开启"),"#1890ff"),n("随机答题功能状态:"+(localStorage.getItem("GPTJsSetting.randomAnswer")==="true"?"已开启":"未开启"),"#1890ff"),n("使用模型:"+(localStorage.getItem("GPTJsSetting.model")||"gpt-3.5-turbo-16k"),"#1890ff"),J("暂无答案",`题型: ${x} 题目: ${o.substring(0,30)}...`,"");const c=document.createElement("div");if(c.textContent="暂无答案,尝试使用AI...",c.style.cssText=` position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: #E6A23C; color: white; padding: 10px 20px; border-radius: 4px; box-shadow: 0 2px 12px 0 rgba(0,0,0,0.1); z-index: 10000; transition: all 0.3s; `,document.body.appendChild(c),setTimeout(()=>{c.style.opacity="0",setTimeout(()=>{document.body.removeChild(c)},500)},3e3),localStorage.getItem("GPTJsSetting.useAI")==="true"){n("已开启AI答题功能,准备获取AI答案...","#1890ff"),ie(o,x).then(p=>{n("AI成功回答,继续处理...","green"),s(p)}).catch(p=>{if(n("AI回答失败: "+p,"red"),localStorage.getItem("GPTJsSetting.randomAnswer")==="true"){n("尝试使用随机答题功能作为备选...","#1890ff");const y=Z(x);n("成功生成随机答案: "+y,"green"),s(y)}else localStorage.setItem("GPTJsSetting.sub",!1),s("")});return}if(localStorage.getItem("GPTJsSetting.randomAnswer")==="true"){n("已开启随机答题功能,准备生成随机答案...","#1890ff");const p=Z(x);n("成功生成随机答案: "+p,"green"),s(p);return}n("未开启AI答题和随机答题功能,留空并继续下一题...","red"),localStorage.setItem("GPTJsSetting.sub",!1),s("")}}catch(u){n("解析响应出错: "+u,"red"),J("解析响应出错",`错误信息: ${u}`,""),r(u)}else n("请求失败,状态码: "+l.status,"red"),J("请求失败",`状态码: ${l.status}`,""),r("请求失败,状态码: "+l.status)},onerror:function(l){n("请求出错: "+l,"red"),J("请求出错",`错误信息: ${l}`,""),r(l)},ontimeout:function(){n("请求超时","red"),J("请求超时","请求答案超时,请检查网络连接",""),r("请求超时")}})})}function Ne(e,t,s){U=i(s).contents();let o=U.find(".CeYan").find(".TiMu");H=U.find(".ZY_sub").find(".btnSubmit"),ne=U.find(".ZY_sub").find(".btnSave"),z(e,t,0,o)}function z(e,t,s,r){if(s==r.length){localStorage.getItem("GPTJsSetting.sub")==="true"?(n("测验处理完成,准备自动提交。","green"),setTimeout(()=>{H.click(),setTimeout(()=>{U.find("#confirmSubWin > div > div > a.bluebtn").click(),n("提交成功,准备切换下一个任务。","green"),S.splice(0,1),E.splice(0,1),setTimeout(()=>{N(e+1,t)},3e3)},3e3)},5e3)):localStorage.getItem("GPTJsSetting.force")==="true"?(n("测验处理完成,存在无答案题目,由于用户设置了强制提交,准备自动提交。","red"),setTimeout(()=>{H.click(),setTimeout(()=>{U.find("#confirmSubWin > div > div > a.bluebtn").click(),n("提交成功,准备切换下一个任务。","green"),S.splice(0,1),E.splice(0,1),setTimeout(()=>{N(e+1,t)},3e3)},3e3)},5e3)):(n("测验处理完成,存在无答案题目或者用户设置不提交,自动保存!","green"),setTimeout(()=>{ne.click(),setTimeout(()=>{n("保存成功,准备切换下一个任务。","green"),S.splice(0,1),E.splice(0,1),setTimeout(()=>{N(e+1,t)},3e3)},3e3)},5e3));return}let o=i(r[s]).find(".Zy_TItle.clearfix > div").html();o=K(o).replace("/.*?/","");let a=K(o),d={单选题:0,多选题:1,填空题:2,判断题:3,简答题:4}[o.match(/^【(.*?)】|$/)[1]],f=[],g;switch(d){case 0:g=i(r[s]).find(".Zy_ulTop li").find("a");var m=[];g.each(function(){var l=i(this).text().replace(/[ABCD]/g,"").trim();m.push(l)}),m=m.join("|"),n("单选题: "+a+` `+m,"blue"),i.each(g,(l,u)=>{f.push(P(i(u).html()))}),_(d,a).then(l=>{if(localStorage.getItem("GPTJsSetting.alterTitle")==="true"){let c=i(r[s]).find(".Zy_TItle.clearfix > div");c.html(c.html()+l)}if(!l||l.trim()===""||l.includes("未找到答案")||l==="暂无答案"){n("未获取到有效答案,跳过此题","red"),localStorage.setItem("GPTJsSetting.sub",!1),setTimeout(()=>{z(e,t,s+1,r)},setting.time);return}i.each(g,(c,p)=>{l.indexOf(P(i(p).html()))!=-1&&(i(g[c]).parent().click(),f.push(["A","B","C","D","E","F","G"][c]))});let u=re(i(r[s]).find(".Zy_ulTop li:nth-child(1)").attr("onclick"),"addcheck(",");").replace("(","").replace(")","");f.length<=0?(n("无法匹配正确答案,请手动选择,跳过","red"),localStorage.setItem("GPTJsSetting.sub",!1)):i(r[s]).find(".Zy_ulTop").parent().find("#answer"+u).val(f.join("")),setTimeout(()=>{z(e,t,s+1,r)},setting.time)}).catch(l=>{n("答案获取失败,跳过此题","red"),setTimeout(()=>{z(e,t,s+1,r)},setting.time)});break;case 1:g=i(r[s]).find(".Zy_ulTop li").find("a");var m=[];g.each(function(){var l=i(this).text().replace(/[ABCD]/g,"").trim();m.push(l)}),m=m.join("|"),n('多选题,用"#"分割多个答案: '+a+` `+m,"blue"),_(d,a).then(l=>{if(localStorage.getItem("GPTJsSetting.alterTitle")==="true"){let c=i(r[s]).find(".Zy_TItle.clearfix > div");c.html(c.html()+l)}i.each(g,(c,p)=>{l.indexOf(P(i(p).html()))!=-1&&(i(g[c]).parent().click(),f.push(["A","B","C","D","E","F","G"][c]))});let u=re(i(r[s]).find(".Zy_ulTop li:nth-child(1)").attr("onclick"),"addcheck(",");").replace("(","").replace(")","");f.length<=0?(n("AI无法完美匹配正确答案,请手动选择,跳过","red"),localStorage.setItem("GPTJsSetting.sub",!1)):i(r[s]).find(".Zy_ulTop").parent().find("#answer"+u).val(f.join("")),setTimeout(()=>{z(e,t,s+1,r)},setting.time)}).catch(l=>{setTimeout(()=>{z(e,t,s+1,r)},setting.time)});break;case 2:let b=i(r[s]).find(".Zy_ulTk .XztiHover1");_(d,a).then(l=>{if(localStorage.getItem("GPTJsSetting.alterTitle")==="true"){let c=i(r[s]).find(".Zy_TItle.clearfix > div");c.html(c.html()+l)}let u=l.split("#");i.each(b,(c,p)=>{setTimeout(()=>{i(p).find("#ueditor_"+c).contents().find(".view p").html(u[c]),i(p).find("textarea").html("

"+u[c]+"

")},300)}),setTimeout(()=>{z(e,t,s+1,r)},setting.time)}).catch(l=>{setTimeout(()=>{z(e,t,s+1,r)},setting.time)});break;case 3:g=i(r[s]).find(".Zy_ulTop li").find("a");let x="正确|是|对|√|T|ri";i.each(g,(l,u)=>{f.push(P(i(u).html()))}),n("判断题,只回答正确或错误: "+a,"blue"),_(d,a).then(l=>{if(localStorage.getItem("GPTJsSetting.alterTitle")==="true"){let c=i(r[s]).find(".Zy_TItle.clearfix > div");c.html(c.html()+l)}if(!l||l.trim()===""||l.includes("未找到答案")||l==="暂无答案"){n("未获取到有效答案,跳过此题","red"),localStorage.setItem("GPTJsSetting.sub",!1),setTimeout(()=>{z(e,t,s+1,r)},setting.time);return}l=x.indexOf(l)!=-1?"对":"错";let u=f.findIndex(c=>c==l);u==-1?(n("未匹配到正确答案,跳过","red"),localStorage.setItem("GPTJsSetting.sub",!1)):i(g[u]).parent().click(),setTimeout(()=>{z(e,t,s+1,r)},setting.time)}).catch(l=>{n("答案获取失败,跳过此题","red"),setTimeout(()=>{z(e,t,s+1,r)},setting.time)});break;case 4:let h=i(r[s]).find(".Zy_ulTk .XztiHover1");_(d,a).then(l=>{l=="暂无答案"&&localStorage.setItem("GPTJsSetting.sub",!1);let u=l.split("#");i.each(h,(c,p)=>{setTimeout(()=>{i(p).find("#ueditor_"+c).contents().find(".view p").html(u[c]),i(p).find("textarea").html("

"+u[c]+"

")},300)}),setTimeout(()=>{z(e,t,s+1,r)},setting.time)}).catch(l=>{setTimeout(()=>{z(e,t,s+1,r)},setting.time)});break}}function fe(e){return new Promise((t,s)=>{GM_xmlhttpRequest({url:API_BASE_URL+"/api/v1/save?v="+GM_info.script.version,data:"data="+encodeURIComponent(JSON.stringify(e)),method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},onload:function(r){try{let o=i.parseJSON(r.responseText);o.code==200?n("答案收录成功!!此次收录"+o.data.total+"道题目,准备处理下一个任务。","green"):n("答案收录失败了,请向作者反馈,准备处理下一个任务。","red"),t()}catch{r.responseText.indexOf("防火墙")!=-1?n("答案收录失败了,已被防火墙拦截,请联系作者手动收录。","red"):n("答案收录失败了,未知错误,请向作者反馈。","red"),t()}}})})}function T(){if(S.length>0){let e="";try{e=S[0].property.name||"任务点"}catch{e="任务点"}J("完成一个任务点",`已完成: ${e}`,"")}else J("没有任务点","当前页面没有可处理的任务点","");S.splice(0,1),E.splice(0,1),setTimeout(O,5e3)}function te(){n("通过missonStart别名调用initializeTaskSystem","blue");try{O()}catch(e){if(n("通过missonStart调用initializeTaskSystem失败: "+e,"red"),F(),S.length<=0)return J("任务点完成","此页面所有任务点已处理完毕,准备跳转页面",""),n("此页面任务处理完毕,准备跳转页面","green"),L();let t=S[0].type;E[0],S[0],t==null&&(t=S[0].property.module),n("尝试继续执行任务: "+t,"orange"),setTimeout(()=>{T()},5e3)}}function P(e){if(!e)return null;let t=e.replace(/<(?!img).*?>/g,"");return t=t.replace(/^【.*?】\s*/,"").replace(/\s*(\d+\.\d+分)$/,"").replace(/ /g,"").replace(new RegExp(" ","gm"),"").trim().replace(/^\s+/,"").replace(/\s+$/,""),t}function K(e){if(!e)return null;let t=P(e);return t=t.replace(/^\d+[\.、]/,"").replace("javascript:void(0);",""),t}function Ze(){var e=i("style:contains(font-cxsecret)");if(e.length){var t=e.text().match(/base64,([\w\W]+?)'/)[1];t=Typr.parse(Me(t))[0];for(var s=JSON.parse(GM_getResourceText("Table")),r={},o=19968;o<40870;o++)e=Typr.U.codeToGlyph(t,o),e&&(e=Typr.U.glyphToPath(t,e),e=ye(JSON.stringify(e)).slice(24),r[o]=s[e]);i(".font-cxsecret").html(function(a,d){return i.each(r,function(f,g){f=String.fromCharCode(f),f=new RegExp(f,"g"),g=String.fromCharCode(g),d=d.replace(f,g)}),d}).removeClass("font-cxsecret")}}function Me(e){for(var t=window.atob(e),s=new Uint8Array(t.length),r=0;r{if(t.querySelector(".notification-toggle-btn"))return;const s=document.createElement("div");s.className="notification-toggle-btn";const r=localStorage.getItem("GPTJsSetting.notification")!=="false";s.innerHTML=r?'':'',s.style.cssText=` position: absolute; top: 5px; right: 5px; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; background-color: ${r?"#4CAF50":"#FF9800"}; color: white; border-radius: 50%; cursor: pointer; font-size: 12px; z-index: 1000; opacity: 0.7; transition: all 0.3s ease; `,s.addEventListener("mouseover",()=>{s.style.opacity="1"}),s.addEventListener("mouseout",()=>{s.style.opacity="0.7"}),s.addEventListener("click",()=>{const o=localStorage.getItem("GPTJsSetting.notification")!=="false";localStorage.setItem("GPTJsSetting.notification",!o),s.innerHTML=o?'':'',s.style.backgroundColor=o?"#FF9800":"#4CAF50";const a=document.getElementById("GPTJsSetting.notification");a&&(a.checked=!o);const d=o?"桌面通知已关闭":"桌面通知已开启",f=document.createElement("div");f.textContent=d,f.style.cssText=` position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: ${o?"#FF9800":"#4CAF50"}; color: white; padding: 10px 20px; border-radius: 4px; box-shadow: 0 2px 12px 0 rgba(0,0,0,0.1); z-index: 10000; transition: all 0.3s; `,document.body.appendChild(f),setTimeout(()=>{f.style.opacity="0",setTimeout(()=>{document.body.contains(f)&&document.body.removeChild(f)},500)},3e3)}),t.style.position="relative",t.appendChild(s)})}function Re(){const e=new MutationObserver(s=>{s.forEach(r=>{r.addedNodes&&r.addedNodes.length>0&&r.addedNodes.forEach(o=>{o.nodeType===1&&o.classList&&o.classList.contains("gpt-box")&&ae()})})}),t={childList:!0,subtree:!0};e.observe(document.body,t),ae()}window.addEventListener("load",Re);document.getElementById("ai-send-btn").addEventListener("click",Te);document.getElementById("ai-copy-btn").addEventListener("click",we);function Te(){const e=document.getElementById("ai-question").value.trim();if(!e){document.getElementById("ai-answer").innerText="请输入问题内容";return}document.getElementById("ai-answer").innerText="正在思考中,请稍候...";const t=document.getElementById("modelSelect").value;let s=localStorage.getItem("GPTJsSetting.key")||localStorage.getItem("tiku_key")||"";if(!s){document.getElementById("ai-answer").innerText="请在设置中配置您的Key",n("未配置Key,请在设置中配置您的Key","red");return}n("使用模型: "+t,"#1890ff");const r={messages:[{role:"system",search:"true",content:"你是一个专业的答题助手,请帮我解答以下问题。"},{role:"user",content:e}],model:t};GM_xmlhttpRequest({method:"POST",url:API_BASE_URL+"?act=ai",headers:{Accept:"application/json",Authorization:"Bearer "+s,"Content-Type":"application/json"},data:JSON.stringify(r),timeout:1e4,onload:function(o){try{const a=JSON.parse(o.responseText);if(o.status===200){if(a.code===1001){document.getElementById("ai-answer").innerText="错误: "+a.msg,n("AI回答失败: "+a.msg,"red");return}if((a.code===1e3||a.code===200)&&a.data&&a.data.answer){const d=a.data.answer;document.getElementById("ai-answer").innerText=d,n("AI回答成功","#10b981")}else document.getElementById("ai-answer").innerText="获取答案失败: API返回格式错误",n("AI回答失败: API返回格式错误","red")}else document.getElementById("ai-answer").innerText="获取答案失败: 服务器响应错误 "+o.status,n("AI回答失败: 服务器响应错误 "+o.status,"red")}catch(a){document.getElementById("ai-answer").innerText="获取答案失败: "+a.message,n("AI回答失败: "+a.message,"red")}},onerror:function(o){document.getElementById("ai-answer").innerText="获取答案失败,请检查网络连接",n("AI请求错误: "+o.message,"red")},ontimeout:function(){document.getElementById("ai-answer").innerText="获取答案失败,请求超时",n("AI请求超时","red")}})}function we(){const e=document.getElementById("ai-answer").innerText;e&&e!=="正在思考中,请稍候..."&&e!=="AI 助手已准备就绪,请输入您的问题..."&&navigator.clipboard.writeText(e).then(()=>{n("答案已复制到剪贴板","#10b981");const t=document.getElementById("ai-copy-btn"),s=t.innerText;t.innerText="复制成功",t.style.backgroundColor="#52c41a",setTimeout(()=>{t.innerText=s,t.style.backgroundColor="#722ed1"},1500)}).catch(t=>{n("复制失败: "+t,"red")})}function Ye(){const e=document.querySelector(".gpt-box"),t=document.getElementById("ai-log-toggle");e&&(e.style.display==="none"?(e.style.display="block",t.innerText="隐藏日志",t.style.backgroundColor="#1890ff",localStorage.setItem("GPTJsSetting.hideGptBox","false")):(e.style.display="none",t.innerText="显示日志",t.style.backgroundColor="#8c8c8c",localStorage.setItem("GPTJsSetting.hideGptBox","true")))}function We(){const e=document.getElementById("ai-log-toggle");if(!e)return;e.addEventListener("click",Ye),localStorage.getItem("GPTJsSetting.hideGptBox")==="true"?(e.innerText="显示日志",e.style.backgroundColor="#8c8c8c"):(e.innerText="隐藏日志",e.style.backgroundColor="#1890ff")}document.getElementById("ai-send-btn").addEventListener("click",Te);document.getElementById("ai-copy-btn").addEventListener("click",we);setTimeout(()=>{document.getElementById("ai-log-toggle")&&We()},1e3);function ie(e,t){return new Promise((s,r)=>{if(!e||e.trim()===""){r("问题不能为空");return}n(`尝试使用AI回答问题: ${e.substring(0,30)}...`,"#1890ff"),n(`题型: ${t||"未知题型"}`,"#1890ff");const o=localStorage.getItem("GPTJsSetting.model")||"gpt-3.5-turbo-16k";n(`使用模型: ${o}`,"#1890ff");let a=localStorage.getItem("GPTJsSetting.key")||localStorage.getItem("tiku_key")||"";if(!a){n("未配置Key,无法使用AI回答","red"),r("未配置Key");return}let d="你是一个专业的答题助手。";t&&(d+=`这是一道${t},请给出准确答案。`,t.includes("单选题")||t.includes("多选题")?d+="请直接给出选项字母,例如A或ABC。":t.includes("判断题")?d+="请直接回答'正确'或'错误'。":t.includes("填空题")&&(d+="请直接给出填空内容,无需额外说明。"));const f={messages:[{role:"system",search:"true",content:d},{role:"user",content:e}],model:o};let g=!1;const m=setTimeout(()=>{g=!0,n("AI请求超时,未收到响应","red"),r("请求超时,未收到响应")},2e4);try{GM_xmlhttpRequest({method:"POST",url:API_BASE_URL+"?act=autoai",headers:{Accept:"application/json",Authorization:"Bearer "+a,"Content-Type":"application/json"},data:JSON.stringify(f),timeout:15e3,onload:function(b){if(clearTimeout(m),!g)try{if(!b.responseText){n("AI响应内容为空","red"),r("响应内容为空");return}const x=JSON.parse(b.responseText);if(b.status===200){if(x.code===1001){n("AI回答失败: "+x.msg,"red"),r(x.msg);return}if((x.code===1e3||x.code===200)&&x.data&&x.data.answer){const h=x.data.answer;if(!h.trim()||h.trim()==="无法回答"||h.trim()==="我不知道"){n("AI回答内容为空或无意义","red"),r("无有效答案内容");return}let l=h,u=!1;if(t&&(t.includes("单选题")||t.includes("多选题"))){const c=h.match(/(?:^|\s|答案[::]?\s*)([A-D]+)(?:\s|$|\.)/i);c&&c[1]&&(l=c[1].toUpperCase(),u=!0)}else if(t&&t.includes("判断题"))h.includes("正确")||/^(对|是|√|T|ri|true|yes)$/i.test(h.trim())?(l="正确",u=!0):(h.includes("错误")||/^(错|否|×|F|wr|false|no)$/i.test(h.trim()))&&(l="错误",u=!0);else if(t&&t.includes("填空题")){if(h.includes("答案:")||h.includes("答案:")){const c=h.split(/答案[::]/);c.length>1&&(l=c[1].trim(),l=l.split(/[\n\r]+/)[0].trim(),n("从AI回答中提取填空内容: "+l,"#10b981"),u=!0)}l=l.replace(/^['"\[\((【]|['"\]\))】]$/g,""),n("清理后的填空答案: "+l,"#10b981")}if(!u&&(t.includes("单选题")||t.includes("多选题")||t.includes("判断题"))){n("无法从AI回答中提取有效格式答案","red"),r("无法提取有效答案格式");return}n("最终处理后的AI答案: "+l,"green"),s(l)}else n("AI响应格式不正确或答案为空","red"),r("无法提取有效答案")}else n("AI请求返回非200状态码: "+b.status,"red"),r("请求失败, 状态码: "+b.status)}catch(x){n("处理AI响应时出错: "+x.message,"red"),r("解析响应失败: "+x.message)}},onerror:function(b){clearTimeout(m),!g&&(n("AI请求发送失败: "+(b.statusText||b),"red"),r("请求发送失败: "+(b.statusText||b)))},ontimeout:function(){clearTimeout(m),!g&&(n("AI请求超时","red"),r("请求超时"))}})}catch(b){clearTimeout(m),n("发送AI请求时出错: "+b.message,"red"),r("发送请求失败: "+b.message)}})}function Z(e){n("准备使用随机答题功能...","orange"),e||(e="未知题型",n("题型未知,默认使用单选题随机答案","orange"));let t="";if(e.includes("单选题")){const s=["A","B","C","D"];t=s[Math.floor(Math.random()*s.length)],n("随机生成单选题答案: "+t,"#E6A23C")}else if(e.includes("多选题")){const s=["A","B","C","D"],r=Math.floor(Math.random()*3)+1;t=[...s].sort(()=>.5-Math.random()).slice(0,r).sort().join(""),n("随机生成多选题答案: "+t,"#E6A23C")}else if(e.includes("判断题"))t=Math.random()>.5?"正确":"错误",n("随机生成判断题答案: "+t,"#E6A23C");else if(e.includes("填空题"))t="随机答案"+Math.floor(Math.random()*1e3),n("随机生成填空题答案: "+t,"#E6A23C");else{const s=["A","B","C","D"];t=s[Math.floor(Math.random()*s.length)],n("随机生成未知题型答案: "+t,"#E6A23C")}return J("随机答题",`题型: ${e} 随机答案: ${t}`,""),t}