temp
This commit is contained in:
@ -17,5 +17,12 @@
|
||||
"128": "assets/logo.png"
|
||||
},
|
||||
"default_locale": "zh_CN",
|
||||
"permissions": []
|
||||
"permissions": [
|
||||
"offscreen"
|
||||
],
|
||||
"sandbox": {
|
||||
"pages": [
|
||||
"sandbox.html"
|
||||
]
|
||||
}
|
||||
}
|
10
src/pages/sandbox.html
Normal file
10
src/pages/sandbox.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Sandbox</title>
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
3
src/sandbox.ts
Normal file
3
src/sandbox.ts
Normal file
@ -0,0 +1,3 @@
|
||||
chrome.runtime.onMessage.addListener((data) => {
|
||||
console.log(data);
|
||||
});
|
@ -0,0 +1,20 @@
|
||||
|
||||
|
||||
|
||||
async function setupOffscreenDocument() {
|
||||
// 创建运行后台脚本的沙盒环境
|
||||
await chrome.offscreen.createDocument({
|
||||
url: "src/sandbox.html",
|
||||
reasons: [chrome.offscreen.Reason.DOM_SCRAPING],
|
||||
justification: "background script",
|
||||
});
|
||||
|
||||
// Send message to offscreen document
|
||||
chrome.runtime.sendMessage({
|
||||
type: "init",
|
||||
target: "offscreen",
|
||||
data: { init: "1" },
|
||||
});
|
||||
}
|
||||
|
||||
setupOffscreenDocument();
|
||||
|
Reference in New Issue
Block a user