docs: Update injectScript docs to match example from examples repo (#1240)

Co-authored-by: Aaron <aaronklinker1@gmail.com>
This commit is contained in:
spookyuser
2024-12-03 20:23:33 +02:00
committed by GitHub
parent 4ce178c592
commit c2f5efbde4
+10 -5
View File
@@ -548,16 +548,21 @@ To use `injectScript`, we need two entrypoints, one content script and one unlis
```ts
// entrypoints/example-main-world.ts
export default defineUnlistedScript(() => {
console.log('Hello from the main world!');
console.log('Hello from the main world');
});
```
```ts
// entrypoints/example.content.ts
export default defineContentScript(async () => {
await injectScript('/example-main-world.js', {
keepInDom: true,
});
export default defineContentScript({
matches: ['*://*/*'],
async main() {
console.log('Injecting script...');
await injectScript('/example-main-world.js', {
keepInDom: true,
});
console.log('Done!');
},
});
```