As the title says, after I load the extension, background loads (shown by alert message), but then onCommand
doesn't work. I loaded the extension to Chrome and it worked only once (not the first time when I loaded the extension, but when I clicked the hot key).
I am using Canary.
Background.js
alert('a');
chrome.commands.onCommand.addListener(function (command) {
alert('clicked');
if (command === "toggle-feature") {
chrome.tabs.query({}, function (tabs) {
alert('tabs');
chrome.tabs.executeScript(tabs[1].id, {"file": "content_script.js"});
});
}
});
manifest.json
{
"manifest_version": 2,
"name": "Extractor",
"version": "1",
"description": "Extract",
"icons": {
"16": "logo16.png",
"48": "logo48.png",
"128": "logo128.png"
},
"page_action": {
"default_icon": {
"16": "logo16.png",
"48": "logo48.png",
"128": "logo128.png"
},
"default_title": "Extractor"
},
"background": {
"scripts": ["background.js"],
"persistent": true
},
"permissions": [
"tabs",
"https://www.msn.com/*",
"activeTab",
"http://*/*",
"https://*/*"
],
"commands": {
"toggle-feature": {
"suggested_key": {
"default": "Ctrl+Shift+1",
"windows": "Ctrl+Shift+2"
},
"description": "Extract now"
}
}
}
I tried to remove and change persistent value but with no luck.
I am guessing this is a more fundamental problem maybe with Chrome. I disabled cache in developer mode and also removed then installed the extension.