Skip to content

wxt

字数: 0 字 时长: 0 分钟

https://wxt.dev/

获取 chrome 中的书签图标

添加权限

ts
export default defineConfig({
  modules: ['@wxt-dev/module-vue'],
  manifest: {
    manifest_version: 3,
    permissions: [
      "bookmarks",
      "history",
      "tabs",
      "favicon"
    ],
    web_accessible_resources: [
      {
        "resources": ["_favicon/*"],
        "matches": ["<all_urls>"],
        "extension_ids": ["*"]
      }
    ]
  },
});

访问图标 URL

ts
`chrome-extension://${browser.runtime.id}/_favicon/?pageUrl=${encodeURIComponent(url)}&size=40`;

如果不是wxt,要把browser.runtime替换为chrome.runtime