I made a chrome extension which run after user click on the icon (browser action). After user click on the icon the file background.js is running. It will check the tabs and I inject a js file in the tab.
File background.js
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.query({'url':"URL TO SEARCH"}, function(tabs) {
//console.log(tabs[0].id);
chrome.tabs.executeScript(tabs[0].id, {file: "do.js"}, function (test){
console.log(test);
});
});
});
The file do.js do some stuff (it works no issue) and i would like to return a value at the end of do.js but I'm stuck in code as I don't find the solution.
do.js
if ( Test1) {
do something;
return ok; //how to do that ????
}else{
do someting;
return not ok; //how to do ???
}
My question what is the code to add to do.js to return a simple text value. I have read this question, but i don't understand the answer.
Below the manifest.json
"background": {
"scripts": ["background.js"]
},
"permissions": [
"tabs", "http://*/*", "https://*/*","file:///*"
],
"browser_action": {
"default_title": "Mute Hangout",
"default_icon": "icon16.png"
},
"manifest_version": 2
Thank you