I'm trying to get the DOM node of the current selected text. I'm building a chrome extension and trying to do so from the background file. I know I can get the selection using:
chrome.tabs.executeScript(tab.id, {code:
'chrome.extension.onRequest.addListener(function(request, sender, sendResponse)
{if (request.method == "getSelection")
sendResponse({data:window.getSelection().toString()});
else sendResponse({});});'
});"
chrome.tabs.sendRequest(tab.id, {method: "getSelection"}, function(response){
return respose.data;
});
But I don't know how to get the node (for traversing).
Any ideas?
thanks