酷代码 AI
菜单
全部AI  /  热门  /  AI写代码神器
服务商

async function emulateexamination(answers, startbuttonselector, primarynextbuttonselector, secondarynextbuttonselector, answerhandler, examinationname, size = 100, interval = 3000, afterstart = async () => { }) { let isexaminationstarted = false; let count = 0; const next = async (nextanswers, nextbutton = null) => { const questionelement = await waitforelementloaded(".exam-content-question"); const questiontext = removestuffs(questionelement.innertext.split("\n")[0])

; if (questiontext) { count++; const answer = getanswer(answers, questiontext); if (answer) { answerhandler(answers, questiontext, answer); } else { const answer = nextanswers[count % size]; answerhandler(answers, questiontext, answer); } if (nextbutton) { nextbutton.click(); } else { document.querySelector(primarynextbuttonselector).click(); } } else { setTimeout(() => next(nextanswers, nextbutton), interval); } }; const handlestart = async () => { if (!isexaminationstarted) { const startbutton = document.querySelector(startbuttonselector); if (startbutton) { startbutton.click(); isexaminationstarted = true; await afterstart(); Promise.resolve(); } else { setTimeout(handlestart, interval); } } }; handlestart(); document.querySelector(primarynextbuttonselector).addEventListener("click", async () => { await next(answers); }); document.querySelector(secondarynextbuttonselector).addEventListener("click", async () => { await next(answers, document.querySelector(secondarynextbuttonselector)); }); return isexaminationstarted; } [2024-10-13 01:02:56 | AI写代码神器 | 983点数解答]

相关提问