-
This question has been bothering me all day directory structure // entrypointsindex/injected.content/injected.ts
export default defineUnlistedScript(() => {
console.log('Hello from injected.ts');
}); // entrypointsindex/injected.content/index.ts
export default defineContentScript({
matches: ['*://www.baidu.com/*'],
runAt: 'document_start',
async main() {
console.log('Injecting script...');
await injectScript('/content-scripts/injected.js', {
keepInDom: true,
});
console.log('Done!');
},
}); // wxt.config.ts
import { defineConfig } from 'wxt';
// See https://wxt.dev/api/config.html
export default defineConfig({
modules: ['@wxt-dev/module-vue'],
manifest: {
web_accessible_resources: [
{
resources: ['content-scripts/injected.js'],
matches: ['*://www.baidu.com/*'],
},
],
permissions: ['scripting'],
}
}); open https://www.baidu.com Uncaught Error: This script should only be loaded in a browser extension. |
Beta Was this translation helpful? Give feedback.
Answered by
aiktb
Sep 25, 2024
Replies: 1 comment 1 reply
-
Put it in |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Ya-hui
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Put it in
entrypoints
directory.