From 6a289bb68305a24b90cacf02b777775014219a6e Mon Sep 17 00:00:00 2001 From: src48597962 <48597962@qq.com> Date: Fri, 31 May 2024 09:41:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20'SrcJyData.js'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SrcJyData.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/SrcJyData.js b/SrcJyData.js index 65d58e15..771dc365 100644 --- a/SrcJyData.js +++ b/SrcJyData.js @@ -522,7 +522,7 @@ function getYiData(jkdata) { let dws = extdata["一级"].split(';'); if(/^json:/.test(dws[0])){ let json = dealJson(gethtml); - eval(`let items = \`${json+'.'+dws[0].replace('json:')}\`;`); + let items = getJsonValue(json, dws[0].replace('json:')); log(items); }else{ @@ -1424,4 +1424,17 @@ function dealJson(html) { html = JSON.parse(html); }catch (e) {} return html; -} \ No newline at end of file +} +//获取对象指定路径值 +function getJsonValue(obj, path) { + const parts = path.split('.'); + let current = obj; + for (let part of parts) { + if (current[part]) { + current = current[part]; + } else { + return undefined; + } + } + return current; +}