From 608e76076d63d3b22c55c0baaf2df008e0b32313 Mon Sep 17 00:00:00 2001 From: enncy <877526278@qq.com> Date: Tue, 31 May 2022 00:05:17 +0800 Subject: [PATCH] =?UTF-8?q?feat(core):=20=E4=BC=98=E5=8C=96=E6=99=BA?= =?UTF-8?q?=E6=85=A7=E6=A0=91=E6=96=87=E5=AD=97=E8=AF=86=E5=88=AB=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/script/zhs/index.ts | 45 +++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/packages/core/src/script/zhs/index.ts b/packages/core/src/script/zhs/index.ts index 713c68d1..1df8806d 100644 --- a/packages/core/src/script/zhs/index.ts +++ b/packages/core/src/script/zhs/index.ts @@ -89,10 +89,49 @@ export const ZHSScript = defineScript({ name: '文本识别脚本', url: [ '**zhihuishu.com/stuExamWeb.html#/webExamList/dohomework**', - '**zhihuishu.com/stuExamWeb.html#/webExamList/doexamination*', - '**zhihuishu.com/atHomeworkExam/stu/homeworkQ/exerciseList**' + '**zhihuishu.com/stuExamWeb.html#/webExamList/doexamination*' ], - start() { + async onload() { + const { zhs } = useContext(); + zhs.isRecognizing = true; + + const interval = setInterval(() => { + const scripts = Array.from(document.querySelectorAll('script')); + for (const script of scripts) { + const params = new URLSearchParams(script.src.substring(script.src.indexOf('?') + 1)); + const json = params.get('json'); + if (json) { + let dtos = []; + try { dtos = JSON.parse(JSON.parse(JSON.parse(json).data[0].data).data); } catch { } + if (dtos.length === 0) { + try { dtos = JSON.parse(JSON.parse(json).data[0].data).data; } catch { } + } + try { + const questionDtos = dtos.rt.examBase.workExamParts.map((p: any) => p.questionDtos).flat(); + questionDtos.map((d: any) => { + d.eid = d.eid.replace(/\\|\/|\?|\*|"|'|<|>|\{|\}|\[|\]|:|\^|\$|!|~|`|=|\+|/g, ''); + return d; + }).forEach((d: any) => { + const desc = document.querySelector('#anchor_' + d.eid)?.parentNode?.parentNode?.querySelector('.subject_describe'); + if (desc) desc.innerHTML = d.name; + }); + zhs.isRecognizing = false; + clearInterval(interval); + break; + } catch { } + } + } + }, 3000); + } + }, + { + name: '页面反反混淆功能', + url: '**zhihuishu.com/videoStudy.html**', + priority: 999, + onstart() { + // @ts-ignore + // eslint-disable-next-line no-extend-native + RegExp.prototype._test = RegExp.prototype.test; // @ts-ignore window.Element.prototype.attachShadow = undefined; // @ts-ignore