How to return multiple element\'s value from Chrome Plugin, tabs.executeScript.
Please suggest in below code.
chrome.tabs.executeScript(
targetTab
chrome.tabs.executeScript
can transfer any JSON-ifiable data, including simple objects/arrays.
chrome.tabs.executeScript(targetTab.id, {
code: '(' + function() {
return {
top: document.querySelector('.top-card').innerHTML,
footer: document.querySelector('.footer').innerHTML,
content: document.querySelector('.content').innerHTML,
};
} + ')()'
}, function(data) {
var myCode = data[0]; // data is an array, item 0 is the main page, 1.. for frames
console.log(myCode.top, myCode.footer);
});