Reputation: 1151
I've searched through stackoverflow and google's extension FAQ but could not seem to find the answer. Browser actions for my chrome extension refuse to work... Here is my code. Note: i've tried using background.html instead of .js - no go. It never calls linker.js.
Manifest.json
{
"name": "name",
"version": "1.0",
"background": "background.js",
"description": "test",
"permissions": ["tabs", "http://*/*", "https://*/*"],
"browser_action": {
"default_title": "Test",
"default_icon": "raindrop.png"
}
}
background.js
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript(null, {file: "linker.js"});
});
linker.js
alert("linker is running");
plus more code here
Does anyone have any ideas?
Upvotes: 0
Views: 3819
Reputation: 1
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript(null,{code:"alert('test!')"});
});
Upvotes: -1
Reputation: 47873
Your manifest needs to be "background_page": "background.html"
. Within background.html
you need to include <script src="background.js"></script>
. This will add the onClicked
listener and it looks like linker.js
should trigger an alert.
Upvotes: 1