maybe someone can explain me how to resolve this problem:
For example I have this code:
let btn = document.getElementById('defbtn');
if (btn != null) {
btn.onclick = function(el) {
chrome.tabs.query({active:true, currentWindow: true}, function(tabs) {
chrome.tabs.executeScript(
tabs[0].id,
{code: "var textP = document.evaluate( 'any_xpath_here', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue.innerHTML;"}
);
});
// How to get value from textP? To execute for example alert(textP);
}
}
How can I access textP value from chrome extension or how can I save textP in a chrome extension variable?