I am currently developing a Chrome extension that will automatically redirect me to a specific URL when I click on the browser action icon.
Here is the code snippet that I am trying to implement:
chrome.browserAction.onClicked.addListener
However, I am encountering the following error:
Uncaught TypeError: Cannot read property 'onClicked' of undefined
Below is my manifest file configuration:
{
"name": "My First Extension",
"version": "1.0",
"description": "Redirects to specified link upon clicking icon",
"browser_action": {
"default_icon": "icon.png",
"default_title": "Perform action"
},
"permissions": ["tabs", "http://*/*"],
"content_scripts": [{
"matches": ["http://*.example.com/*", "https://*.example.com/*"],
"js": ["script.js"]
}],
"icons": {
"16": "icon.png",
"48": "icon.png",
"128": "icon.png"
}
}
This is the content of my JavaScript file:
chrome.browserAction.onClicked.addListener(function(tab) { alert("hi"); });