From ff5f56207931e4565c41242ac78d5d59184f2149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Fri, 19 Apr 2024 11:58:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BFgithub=E6=B2=B9=E7=8C=B4=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=EF=BC=8C=E4=B8=8D=E5=86=8D=E5=BC=BA=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E4=BA=8E=20=E7=AF=A1=E6=94=B9=E7=8C=B4=EF=BC=88tampermonkey?= =?UTF-8?q?=EF=BC=89=E8=84=9A=E6=9C=AC=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/mitmproxy/src/lib/monkey/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/mitmproxy/src/lib/monkey/index.js b/packages/mitmproxy/src/lib/monkey/index.js index 425993b..c877f10 100644 --- a/packages/mitmproxy/src/lib/monkey/index.js +++ b/packages/mitmproxy/src/lib/monkey/index.js @@ -21,7 +21,7 @@ function buildScript (sc, content, scriptName) { icon: sc.icon } const initStr = ` -const DS_init = window.__ds_global__['DS_init'] +const DS_init = (window.__ds_global__ || {})['DS_init'] if (typeof DS_init === 'function') { \tconsole.log("${scriptKey} do DS_init") \tDS_init(${JSON.stringify(options)}); @@ -31,7 +31,7 @@ if (typeof DS_init === 'function') { // 代码3:判断是否启用了脚本 const checkEnabledStr = ` -if (!(window.__ds_global__.GM_getValue || (() => true))("ds_enabled", true)) { +if (!((window.__ds_global__ || {}).GM_getValue || (() => true))("ds_enabled", true)) { \tconsole.log("${scriptKey} disabled") \treturn }` @@ -44,9 +44,9 @@ if (!(window.__ds_global__.GM_getValue || (() => true))("ds_enabled", true)) { } if (item.indexOf('.') > 0) { - grantStr += item + ' = window.__ds_global__[\'' + item + '\'];' + grantStr += item + ' = (window.__ds_global__ || {})[\'' + item + '\'];' } else { - grantStr += 'const ' + item + ' = window.__ds_global__[\'' + item + '\'] || (() => {});' + grantStr += 'const ' + item + ' = (window.__ds_global__ || {})[\'' + item + '\'] || (() => {});' } }