diff --git a/package.json b/package.json index 4f7bda66..396a07a4 100644 --- a/package.json +++ b/package.json @@ -64,4 +64,4 @@ "path": "./node_modules/cz-conventional-changelog" } } -} +} \ No newline at end of file diff --git a/packages/core/src/script/zhs/index.ts b/packages/core/src/script/zhs/index.ts index 9bea5c8d..69e3908d 100644 --- a/packages/core/src/script/zhs/index.ts +++ b/packages/core/src/script/zhs/index.ts @@ -71,7 +71,7 @@ export const ZHSScript = defineScript({ settings.creditStudy = true; // 智慧树视频学习 logger('info', '开始智慧树学分课视频学习'); - await creditStudy(settings); + await creditStudy(); } }, diff --git a/packages/core/src/script/zhs/study.ts b/packages/core/src/script/zhs/study.ts index cb312c31..c7d393e9 100644 --- a/packages/core/src/script/zhs/study.ts +++ b/packages/core/src/script/zhs/study.ts @@ -1,7 +1,6 @@ import { domSearch, domSearchAll, sleep } from '../../core/utils'; import { logger } from '../../logger'; import { message } from '../../main'; -import { ScriptSettings } from '../../scripts'; import { useContext, useSettings } from '../../store'; let stop = false; @@ -9,8 +8,8 @@ let stop = false; /** * zhs 视频学习 */ -export async function study(setting?: ScriptSettings['zhs']['video']) { - const { watchTime = 30, restudy = false } = setting || {}; +export async function study() { + const { watchTime, restudy } = useSettings().zhs.video; logger('info', 'zhs 学习任务开始'); /** 查找任务 */ let list: HTMLLIElement[] = Array.from(document.querySelectorAll('li.clearfix.video')); @@ -30,7 +29,11 @@ export async function study(setting?: ScriptSettings['zhs']['video']) { /** * 实时监测,关闭弹窗测验 */ - setInterval(() => closeTestDialog(), 3000); + setInterval(() => { + const { showProgress } = useSettings().zhs.video; + closeTestDialog(); + fixedVideoProgress(showProgress); + }, 3000); /** * 到达学习时间后,自动关闭 @@ -50,7 +53,7 @@ export async function study(setting?: ScriptSettings['zhs']['video']) { ); item.click(); await sleep(5000); - await watch(setting); + await watch(); } } catch (e) { logger('error', e); @@ -66,8 +69,9 @@ export async function study(setting?: ScriptSettings['zhs']['video']) { * @param setting * @returns */ -export async function watch(setting?: Pick) { - const { volume = 0, playbackRate = 1 } = setting || {}; +export async function watch() { + const { volume, playbackRate, creditStudy } = useSettings().zhs.video; + return new Promise((resolve, reject) => { try { const video = document.querySelector('video') as HTMLVideoElement; @@ -86,8 +90,8 @@ export async function watch(setting?: Pick