mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-04-19 08:28:41 +00:00
修复v3注入脚本失败的bug
This commit is contained in:
parent
d7012997b7
commit
153a2f66f1
@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user