From 153a2f66f1f159ced7e55c222ddf8de8992f8f62 Mon Sep 17 00:00:00 2001 From: xu_yanfeng Date: Sun, 15 Dec 2024 19:52:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dv3=E6=B3=A8=E5=85=A5=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E5=A4=B1=E8=B4=A5=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cc-inspector/src/core/util.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cc-inspector/src/core/util.ts b/cc-inspector/src/core/util.ts index 8ebe6b0..63ad443 100644 --- a/cc-inspector/src/core/util.ts +++ b/cc-inspector/src/core/util.ts @@ -1,14 +1,16 @@ export function injectScript(url: string) { - if (chrome && chrome.extension && chrome.extension.getURL) { - let content = chrome.extension.getURL(url) - console.log(`[cc-inspector] inject script: ${content}`); + if (chrome && chrome.runtime && chrome.runtime.getURL) { + let content = chrome.runtime.getURL(url) const script = document.createElement("script") script.setAttribute("type", "text/javascript") script.setAttribute("src", content) script.onload = function () { - document.body.removeChild(script); + document.head.removeChild(script); } - document.body.appendChild(script) + document.head.appendChild(script) + console.log(`inject script success: ${content}`); + } else { + console.log("inject script failed") } }