Skip to content

Commit

Permalink
fix(script): 修复智慧树答题后不保存的BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
enncy committed Mar 12, 2023
1 parent 7686cf1 commit c56b54f
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions packages/scripts/src/projects/zhs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export const ZHSProject = Project.create({
record?.courses.find((c) => c.name === vue.data.courseInfo.name)?.time || 0
)}`
});
} catch { }
} catch {}
};

const interval = setInterval(async () => {
Expand Down Expand Up @@ -578,7 +578,8 @@ export const ZHSProject = Project.create({
this.event.emit('done');
},

...CommonProject.scripts.settings.cfg, upload: 'nomove',
...CommonProject.scripts.settings.cfg,
upload: 'nomove'
});
};

Expand Down Expand Up @@ -688,7 +689,8 @@ async function watch(

video.play().catch(() => {
$model('alert', {
content: '由于浏览器保护限制,如果要播放带有音量的视频,您必须先点击页面上的任意位置才能进行视频的播放。',
content:
'由于浏览器保护限制,如果要播放带有音量的视频,您必须先点击页面上的任意位置才能进行视频的播放,如果想自动播放,必须静音。',
onClose: async () => {
video.play();
}
Expand Down Expand Up @@ -783,7 +785,7 @@ function waitForQuestionsLoad() {
*/
function hack() {
const vue = $el('.video-study')?.__vue__;
const empty = () => { };
const empty = () => {};
vue.checkout = empty;
vue.notTrustScript = empty;
vue.checkoutNotTrustScript = empty;
Expand Down Expand Up @@ -883,6 +885,18 @@ function gxkWorkOrExam(
worker
.doWork()
.then(async (results) => {
// 保存题目
const text = el('span', '正在保存题目中,请勿操作...');
const modal = $model('alert', { content: text });

for (let index = 0; index < worker.totalQuestionCount; index++) {
// 下一页
$el('div.examPaper_box > div.switch-btn-box > button:nth-child(2)').click();
await $.sleep(1000);
}
text.innerText = '所有题目保存成功。';
setTimeout(() => modal?.remove(), 2000);

if (type === 'exam') {
$message('info', { content: '考试完成,为了安全考虑,请自行检查后自行点击提交!' });
} else {
Expand Down Expand Up @@ -913,21 +927,6 @@ function gxkWorkOrExam(
}
});
}

// 保存题目

const text = el('span', '正在保存题目中,请勿操作...');
const modal = $model('alert', { content: text });

for (let index = 0; index < worker.totalQuestionCount; index++) {
// 下一页
$el('div.examPaper_box > div.switch-btn-box > button:nth-child(2)').click();
await $.sleep(1000);
}
text.innerText = '所有题目保存成功。';
setTimeout(() => modal?.remove(), 3000);

$message('success', { duration: 0, content: '作业已完成。' });
})
.catch((err) => {
$message('error', { content: '答题程序发生错误 : ' + err.message });
Expand Down

0 comments on commit c56b54f

Please sign in to comment.