I use Chrome Extension manifest V3, My manifestV3 configuration is as follows
...
"background": {
"service_worker": "background.js"
},
...
"action": {
"default_icon": {
"16": "img/icon.png",
"32": "img/icon.png",
"48": "img/icon.png",
"64": "img/icon.png",
"128": "img/icon.png"
}
},
...
My background.js
is as follows:
chrome.action.onClicked.addListener(async (tab) => {
console.log(tab);
if (tab.url.startsWith('https://www.google.com')) {
console.log('this is googlepage');
} else {
console.log('this is not googlepage');
}
});
This is very easy, but I can't get the result of console.log
.
Appeal everybody!
How to solve this problem?