As the questions says, I just want to know the difference between background script and content script in chrome extension. When I logged the chrome object in both the scripts, I found the different objects.
Use case
I want to inject my javascript into the page when the icon is clicked So in manifest.json
I added a content script but I am unable to listen to icon click event inside content script.
chrome.browserAction is not defined in chrome object in content script.
Question
How can I listen to click event in content script. Can we include both background and content script ?
This is my manifest.json
{
"name": "First Plugin Testing",
"version": "1.0",
"manifest_version": 2,
"description": "Trying hands on first extension",
"background": { "scripts": ["background.js"] },
"browser_action": {
"default_icon": "icon.png"
},
"permissions": [
"tabs", "http://*/*", "https://*/*"
],
"content_scripts": [
{
"matches": ["http://*/*"],
"js": ["temp.js"]
}
]
}