docs: Add missing web_accessible_resources to injectScript example (#1337)

This commit is contained in:
Nikolay Ponomarev
2025-01-07 03:23:41 +05:00
committed by GitHub
parent 654a54ac79
commit 060e85f90e
+14
View File
@@ -566,6 +566,20 @@ export default defineContentScript({
});
```
```json
export default defineConfig({
manifest: {
// ...
web_accessible_resources: [
{
resources: ["example-main-world.js"],
matches: ["*://*/*"],
}
]
}
});
```
`injectScript` works by creating a `script` element on the page pointing to your script. This loads the script into the page's context so it runs in the main world.
`injectScript` returns a promise, that when resolved, means the script has been evaluated by the browser and you can start communicating with it.