From e2b3cbfe8ef8b764569d03912c01f5158e920a74 Mon Sep 17 00:00:00 2001 From: xyf-mac Date: Thu, 18 Nov 2021 22:49:11 +0800 Subject: [PATCH] watch is cocos game --- source/src/inject/index.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/source/src/inject/index.ts b/source/src/inject/index.ts index 5956139..a772ba4 100644 --- a/source/src/inject/index.ts +++ b/source/src/inject/index.ts @@ -30,9 +30,8 @@ declare const cc: any; class CCInspector { inspectorGameMemoryStorage: Record = {} - init() { - console.log("cc-inspector init ~~~"); - let timer = setInterval(() => { + private watchIsCocosGame() { + const timer = setInterval(() => { if (this._isCocosGame()) { clearInterval(timer) // @ts-ignore @@ -42,6 +41,11 @@ class CCInspector { }) } }, 300) + } + + init() { + console.log("cc-inspector init ~~~"); + this.watchIsCocosGame(); window.addEventListener("message", (event) => { // 接受来自content的事件,有可能也会受到其他插件的 if (!event || !event.data) {