MCPcopy
hub / github.com/ocsjs/ocsjs / study

Function study

packages/scripts/src/projects/icourse.ts:182–258  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

180 handleVideoTest();
181
182 const study = async () => {
183 const lessonName = document.querySelector('.j-lesson .j-up')?.textContent;
184 const currentUnitItem = document.querySelector('.j-unitslist li.current');
185 const unitName = currentUnitItem?.querySelector('.unit-name')?.textContent;
186
187 $msg_and_log('info', `正在学习:${lessonName || ''} - ${unitName || ''}`);
188
189 const isJob = (iconName: string) => currentUnitItem?.querySelector(`[class*=${iconName}]`);
190
191 let hasJob = true;
192
193 if (isJob('u-icon-video')) {
194 await waitForElement('video, audio');
195 await watchMedia(this.cfg.playbackRate, this.cfg.volume);
196 $msg_and_log('info', '视频学习完成');
197 } else if (isJob('u-icon-doc')) {
198 await waitForElement('.ux-pdf-reader');
199 await readPPT(remotePage, this.cfg.readSpeed);
200 $msg_and_log('info', 'PPT完成');
201 } else if (isJob('u-icon-discuss')) {
202 await waitForElement('.j-reply-all');
203 await discussion(remotePage, this.cfg.discussionStrategy);
204 $msg_and_log('info', '讨论完成');
205 } else if (isJob('u-icon-test')) {
206 const replay = await waitForElement('.j-replay');
207 if (replay?.style.display === 'none') {
208 if (this.cfg.enableChapterTest) {
209 await new Promise<void>((resolve) => {
210 ICourseProject.scripts.work.methods.start('chapter-test', canRun, (worker) => {
211 console.log('worker', worker);
212
213 worker.once('done', resolve);
214 worker.once('close', resolve);
215 worker.once('stop', resolve);
216 });
217 });
218
219 $msg_and_log('info', '测验完成');
220 } else {
221 $msg_and_log(
222 'warn',
223 '随堂测验自动答题功能已关闭(上方菜单栏-中国大学MOOC-学习脚本中开启),即将跳过。'
224 );
225 }
226 } else {
227 $msg_and_log('info', '随堂测验已完成,即将跳过。');
228 }
229 } else if (isJob('u-icon-text')) {
230 const key = 'text-job-reload';
231 if ((await $store.getTab(key)) === '1') {
232 $store.setTab(key, '0');
233 $msg_and_log('info', '文档已完成,即将跳过。');
234 } else {
235 // 需要刷新才能完成富文本文档任务点
236 $store.setTab(key, '1');
237 // 文档无需处理
238 $msg_and_log('info', '文档无需处理,将在刷新完成后跳过。');
239 await $.sleep(3000);

Callers 1

methodsFunction · 0.70

Calls 8

waitForElementFunction · 0.90
isJobFunction · 0.85
readPPTFunction · 0.85
discussionFunction · 0.85
canRunFunction · 0.85
gotoNextJobFunction · 0.85
$msg_and_logFunction · 0.70
watchMediaFunction · 0.70

Tested by

no test coverage detected