From 060e85f90ee38badcfcd30efd19990466e560d5d Mon Sep 17 00:00:00 2001 From: Nikolay Ponomarev Date: Tue, 7 Jan 2025 03:23:41 +0500 Subject: [PATCH] docs: Add missing `web_accessible_resources` to `injectScript` example (#1337) --- docs/guide/essentials/content-scripts.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/guide/essentials/content-scripts.md b/docs/guide/essentials/content-scripts.md index eda5288c..70323401 100644 --- a/docs/guide/essentials/content-scripts.md +++ b/docs/guide/essentials/content-scripts.md @@ -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.