Either the '' or 'activeTab' permission is required.
Manifest 从 v2 改成 v3 后,原来的 chrome.tabs.captureVisibleTab() 函数突然报错了。
Either the ‘<all_urls>’ or ‘activeTab’ permission is required.
根据 官方文档 对 captureVisibleTab() 的说明:
In order to call this method, the extension must have either the <all_urls> permission or the activeTab permission.
我们在 manifest.json 中加入了 “<all_urls>”,还是报错
"permissions": [
"tabs",
"webNavigation",
"storage",
"activeTab",
"sidePanel",
"tabCapture",
"<all_urls>"
],
我们跳转到 <all_urls> 的说明,发现 “<all_urls>” 根本不在 “permissions” 的 known strings 里面,它应该属于 “host_permissions”,因此,我们将 manifest.json 内容改成
"host_permissions": [
"<all_urls>"
]
"permissions": [
"tabs",
"webNavigation",
"storage",
"activeTab",
"sidePanel",
"tabCapture"
],
搞定。