I'm trying to mirate an extension from v2 to the v3 manifest.
My goal is by clicking on the extension icon, the option page will open.
Now I checked the migration guide .
So the v2 (is working) is using chrome.browserAction.onClicked.addListener
. And the guide tells me to use chrome.action.onClicked.addListener
in v3
So I made a manifest:
{
"manifest_version": 3,
"version": "0.0.3",
"name": "Live_option_page",
"description": "build live option page with Vuetify 3",
"minimum_chrome_version": 93,
"icons": {
"16": "images/16x16.png"
},
"action": {
"default_icon": "images/16x16.png"
},
"background": {
"service_worker": "background/index.js"
},
"web_accessible_resources": [{
"resources": ["/options/*"],
"matches": ["<all_urls>"]
}],
"options_ui": {
"page": "options/index.html",
"open_in_tab": true
},
"permissions": [
"activeTab",
"tabs",
"browser_action"
]
}
Now I have a service_worker /background/index.js
const API = chrome || browser;
console.log(API.action) // => will print undefined
API.action.onClicked.addListener((tab) => {
console.log("clicked icon on tab ", tab);
API.tabs.create({url: "options/index.html"});
})
So the Service Worker crashed, and chrome.action is undefined.
chrome.action
is nowhere to be find even though I am using manifest v3 and I am trying to use it in the background. – Kandi