最近在使用 wxt 框架开发浏览器扩展,记录一些问题。https://wxt.dev/1. 隔离脚本与网站本身的样式使用Shadow Root,可以不让 content-scripts 侵入式影响网站本身,然后引入并渲染 App.vue 组件。import'./style.css';import{createApp}from'vue';importAppfrom'./App.vue';exportdefaultdefineContentScript({matches:['https://google.com/*'],cssInjectionMode:'ui',asyncmain(ctx){constui=awaitcreateShadowRootUi(ctx,{name:'example-ui',position:'inline',anchor:'body',onMount:(container)=>{constapp=createApp(App);app.mount(container);returnapp;},onRemove:(app)=>{app?.unmount();},});ui.mount();},});2. 在 config.js 中配置import{defineConfig}from'wxt';importpkgfrom'./package.json';// Se
...
继续阅读
(2)