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

Function study

packages/scripts/src/projects/zhs.ts:910–976  ·  view source on GitHub ↗
(opts: { next: boolean })

Source from the content-addressed store, hash-verified

908 const remotePage = processor.remotePage;
909
910 const study = async (opts: { next: boolean }) => {
911 if (state.study.stop === false) {
912 const item = processor.getNext({ next: opts.next, restudy: this.cfg.restudy });
913 if (item) {
914 const msg = '即将学习:' + processor.getChapterName(item);
915 $message.info({ content: msg });
916 $console.log(msg);
917 await $.sleep(3000);
918 // 最小化脚本窗口
919 $render.moveToEdge();
920 // 点击侧边栏任务
921 if (remotePage) {
922 if (type === '新共享课') {
923 await remotePage.click('.title-box');
924 await $.sleep(200);
925 }
926 await remotePage.click(item);
927 await $.sleep(1000);
928 // 两次点击修复黑屏问题
929 await remotePage.click(item);
930 await $.sleep(1000);
931 } else {
932 item.click();
933 }
934
935 // 适配AI助教课程PPT跳过
936 if (type === 'AI课程' && document.querySelector('.preview-warp .doc-box,.preview-warp .ppt-box')) {
937 $message.info({ content: '检测到PPT资源,即将跳过...' });
938 await $.sleep(2000);
939 study({ next: true });
940 return;
941 }
942
943 watch(
944 processor,
945 {
946 reloadWhenError: this.cfg.reloadWhenError,
947 volume: this.cfg.volume,
948 playbackRate: this.cfg.playbackRate,
949 definition: this.cfg.definition
950 },
951 {
952 reload() {
953 // 旧共享课页面点击右侧栏就能重新加载
954 if (type === '共享课') {
955 study({ next: false });
956 } else {
957 location.reload();
958 }
959 },
960 onended({ next }) {
961 study({ next });
962 }
963 }
964 );
965 } else {
966 finishAlert();
967 }

Callers 3

reloadFunction · 0.70
onendedFunction · 0.70
oncompleteFunction · 0.70

Calls 4

watchFunction · 0.85
finishAlertFunction · 0.85
getNextMethod · 0.65
getChapterNameMethod · 0.65

Tested by

no test coverage detected