I have the following code in my Chrome Extension.
function convert(info,tab) {
function modifyDOM(tab) {
//code that wants access to the tab parameter from convert()
}
chrome.tabs.executeScript({
code: '(' + modifyDOM + ')();'
}, (results) => {
console.log(results[0]);
});
}
I want to pass the "tab" parameter from convert() into modifyDOM(), but everything I have tried has failed and I am out of ideas.
I tried doing something like this, but that results in an error.
code: '(' + modifyDOM + ')(' + tab + ');'
VM581:31 Uncaught SyntaxError: Unexpected identifier
I also tried adding a query in modifyDOM(), but that threw an error as well.
chrome.tabs.getSelected(null, function(tab){
console.log(tab);
});
VM580:3 Uncaught TypeError: Cannot read property 'query' of undefined at modifyDOM (:3:19) at :37:7