The question may be stupid, I've just started learning chrome API. But I really have become exhausted when looking for an answer. Here we are:
When I'm using this construction, everything is A-OK:
chrome.tabs.executeScript(tabID, { file: "jquery.js" }, function() {
chrome.tabs.executeScript(tabID, { file: "script.js" }, function(res) {
alert(res); // I can use this result inside this block
});
});
The matter is that I'd like to encapsulate this code into a function like this:
function aFunction( tabID )
{
chrome.tabs.executeScript(tabID, { file: "jquery.js" }, function() {
chrome.tabs.executeScript(tabID, { file: "script.js" }, function(res) {
return res;
});
});
}
Then I use the function this way:
alert(aFunction(tabID));
The message provided by this alert-instruction is "undefined". I tried many ways to write the function, but I constantly get "undefined" as a returned result.
Hope there is a way to implament what I'd like to.
Thanks in advance.