On injecting the script by using command
chrome.tabs.executeScript(
null, {file: \"dialog.js\"});
throwing error
Unchecked runti
Please explicitly set the tabId
parameter of executeScript
, which by default would be the active tab of the current window.
If you couldn't get tabId
directly, use chrome.tabs.query
to query tab state.
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
for(var i = 0; i<tabs.length;i++) {
chrome.tabs.executeScript(tabs[i].id, {"file": "dialog.js"});
}
});
And don't forget add "web_accessible_resources": ["dialog.js"]
in your manifest.json