测视例

This commit is contained in:
xu_yanfeng 2024-12-14 10:12:00 +08:00
parent 625b6d6ee9
commit d7012997b7
15 changed files with 124 additions and 0 deletions

9
hello-chrome/.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,9 @@
{
"files.autoSave": "onFocusChange",
"[html]": {
"editor.suggest.insertMode": "replace",
"editor.formatOnSave": true,
"editor.formatOnType": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}

View File

@ -0,0 +1 @@
console.log("background.js")

1
hello-chrome/content.js Normal file
View File

@ -0,0 +1 @@
console.log("content.js")

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="" style="width: 100%; height: 100%; margin: 0; padding: 0">
<head>
<title>devtools</title>
<script defer src="devtools.js"></script>
</head>
<body style="width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden">
devtools
</body>
</html>

1
hello-chrome/devtools.js Normal file
View File

@ -0,0 +1 @@
console.log("devtools.js");

BIN
hello-chrome/icons/48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

19
hello-chrome/index.html Normal file
View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="" style="width: 100%; height: 100%; margin: 0; padding: 0">
<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>index</title>
<script defer src="index.js"></script>
</head>
<body style="width: 100%; height: 100%; margin: 0; padding: 0">
<script type="text/javascript">
const str = '[{"label":"devtools.html","href":"devtools.html"},{"label":"options.html","href":"options.html"},{"label":"popup.html","href":"popup.html"}]';
window.pluginPanels = JSON.parse(str);
</script>
<div id="app" style="width: 100%; height: 100%; margin: 0; padding: 0; background-color: #ffffff; display: flex; flex-direction: column"></div>
</body>
</html>

1
hello-chrome/index.js Normal file
View File

@ -0,0 +1 @@
console.log("index.js")

1
hello-chrome/inject.js Normal file
View File

@ -0,0 +1 @@
console.log("inject")

View File

@ -0,0 +1,58 @@
{
"manifest_version": 3,
"description": "hello world",
"icons": {
"48": "./icons/48.png"
},
"devtools_page": "devtools.html",
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"js": [
"content.js"
],
"run_at": "document_end",
"all_frames": true
}
],
"options_ui": {
"page": "options.html",
"browser_style": true
},
"name": "helloworld",
"version": "2.1.0",
"host_permissions": [
"wss://*/*",
"ws://*/*",
"activeTab",
"<all_urls>",
"*://*/*",
"tabs",
"http://*/*",
"https://*/*",
"audio",
"system.cpu",
"clipboardRead",
"clipboardWrite",
"system.memory",
"processes",
"tabs",
"storage",
"nativeMessaging",
"contextMenus",
"notifications"
],
"action": {
"default_popup": "popup.html",
"default_icon": {
"48": "./icons/48.png"
},
"default_title": "hello-world"
},
"background": {
"service_worker": "background.js",
"type": "module"
}
}

10
hello-chrome/options.html Normal file
View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="" style="width: 100%; height: 100%; margin: 0; padding: 0">
<head>
<title>options</title>
<script defer src="options.js"></script>
</head>
<body style="width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden">
options
</body>
</html>

1
hello-chrome/options.js Normal file
View File

@ -0,0 +1 @@
console.log('options.js')

10
hello-chrome/popup.html Normal file
View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="" style="width: 100%; height: 100%; margin: 0; padding: 0">
<head>
<title>popup</title>
<script defer src="popup.js"></script>
</head>
<body style="width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden">
popup
</body>
</html>

1
hello-chrome/popup.js Normal file
View File

@ -0,0 +1 @@
console.log("popup")

1
hello-chrome/readme.md Normal file
View File

@ -0,0 +1 @@
使用原生js编写的Chrome插件方便我理解一些逻辑