MCPcopy Create free account
hub / github.com/Xu22Web/tech-study-js / doingExam

Function doingExam

tech-study.js:3095–3442  ·  view source on GitHub ↗

* @description 答题

(type)

Source from the content-addressed store, hash-verified

3093 * @description 答题
3094 */
3095async function doingExam(type) {
3096 // 下一个按钮
3097 let nextButton;
3098 // 下一个文本
3099 let nextText;
3100 // 保存答案
3101 let shouldSaveAnswer = false;
3102 while (true) {
3103 // 先等等再开始做题
3104 await sleep(2500);
3105 // 暂停
3106 await examPauseLock();
3107 // 获取下一个按钮
3108 nextButton = await getNextButton();
3109 // 下一个文本
3110 nextText = nextButton.innerText.replaceAll(' ', '');
3111 // 结束
3112 const finish = ['再练一次', '再来一组', '查看解析'];
3113 if (finish.includes(nextButton.innerText)) {
3114 break;
3115 }
3116 // 点击提示
3117 $$('.tips')[0]?.click();
3118 // 所有提示
3119 const allTips = $$('.line-feed font[color]');
3120 // 答案
3121 const answers = allTips.map((tip) => tip.innerText.trim());
3122 // 获取题目的文本内容
3123 const question = $$('.q-body')[0].innerText;
3124 // 等待一段时间
3125 await sleep(1500);
3126 // 暂停
3127 await examPauseLock();
3128 // 选项按钮
3129 const allBtns = $$('.q-answer');
3130 // 所有填空
3131 const blanks = $$('input[type=text][class=blank]');
3132 // 问题类型
3133 const questionType = ($$('.q-header')[0].innerText.substring(0, 3));
3134 // 暂停
3135 await examPauseLock();
3136 // 题型分类作答
3137 switch (questionType) {
3138 case '填空题': {
3139 // 根据提示作答
3140 if (answers.length) {
3141 const res = handleBlankInput(answers);
3142 // 成功
3143 if (res) {
3144 break;
3145 }
3146 }
3147 // 创建提示
3148 createTip('答案异常, 尝试网络题库获取!');
3149 log('正在获取答案...');
3150 // 尝试题库获取
3151 const answersNetwork = await getAnswer(question);
3152 log(`获取答案${answersNetwork.length ? '成功' : '失败'}!`, {

Callers 1

tech-study.jsFile · 0.70

Calls 15

sleepFunction · 0.70
examPauseLockFunction · 0.70
getNextButtonFunction · 0.70
$$Function · 0.70
handleBlankInputFunction · 0.70
createTipFunction · 0.70
logFunction · 0.70
getAnswerFunction · 0.70
handleBlankInputRandFunction · 0.70
pushModalFunction · 0.70
handleChoiceBtnFunction · 0.70
handleMutiplyChoiceRandFunction · 0.70

Tested by

no test coverage detected