MCPcopy
hub / github.com/ocsjs/ocsjs / handleTestDialog

Method handleTestDialog

packages/scripts/src/projects/zhs.ts:466–521  ·  view source on GitHub ↗
(remotePage?: RemotePage)

Source from the content-addressed store, hash-verified

464 }
465
466 async handleTestDialog(remotePage?: RemotePage) {
467 const question_box = $el('.ai-class-exercise-dialog');
468 if (question_box) {
469 const options = $$el('.ques-list .item .option');
470 $message.info('正在关闭弹窗测验...');
471 if (options.length !== 0) {
472 await waitForCaptcha();
473 // 最小化脚本窗口
474 CommonProject.scripts.render.methods.minimize();
475 CommonProject.scripts.render.methods.setPosition(100, 200);
476 // 随机选
477 const random = Math.floor(Math.random() * options.length);
478 await $.sleep(1000);
479 if (remotePage) {
480 await remotePage.click(options[random]);
481 } else {
482 options[random].click();
483 }
484
485 await $.sleep(1000);
486 }
487 await $.sleep(1000);
488
489 const submit_btn = $el('.ai-class-exercise-dialog .el-dialog__footer .el-button.btn');
490 if (submit_btn) {
491 if (remotePage) {
492 await remotePage.hover('.ai-class-exercise-dialog .el-dialog__footer .el-button.btn');
493 await remotePage.click('.ai-class-exercise-dialog .el-dialog__footer .el-button.btn');
494 } else {
495 submit_btn.click();
496 }
497 }
498
499 const close_btn = $el('.ai-class-exercise-dialog .header-icon');
500 if (close_btn) {
501 if (remotePage) {
502 await remotePage.hover('.ai-class-exercise-dialog .header-icon');
503 await remotePage.click('.ai-class-exercise-dialog .header-icon');
504 } else {
505 close_btn.click();
506 }
507 }
508
509 // 如果无法关闭弹窗,后续版本只能强制删除
510 // await $.sleep(1000);
511 // document.querySelector('.components-box.has-compoent')?.remove();
512 // document.querySelector('.transparent-mask')?.remove();
513 $message.info('弹窗测验已关闭');
514 }
515
516 /**
517 * 每过三秒递归检测是否有弹窗
518 */
519 await $.sleep(3000);
520 await this.handleTestDialog(remotePage);
521 }
522}
523

Callers 1

oncompleteFunction · 0.95

Calls 1

waitForCaptchaFunction · 0.85

Tested by

no test coverage detected