This function has a callback like function(array of any result) {...};
But I don’t know what is the result means.
For example,
chrome.tabs..executeScript(null,
{code:"var x = 10"},
function(){});
how to return the x to the callback?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The result of a script is the last expression being evaluated. So in your example you could use:
This will log [10] to the extension’s console.
results is actually an array of values because if the page has more than one frame you can specify that the script should be injected in each one of them and get the result of all injections. See the specification for executeScript. If you don’t specify allFrames: true, then results will always be a single element array.