I'm getting an URL via content script and try to pass it to my background page via sendMessage but I receive [object Object]
.
content script:
var kom = document.querySelectorAll("a[href*='permalink']");
var linkX = kom[0];
chrome.runtime.sendMessage(
{
link: linkX
});
background script:
chrome.runtime.onMessage.addListener(function(response, sender, sendResponse) {
console.log("MY LINK: " + response.link);
});
I found that you can't pass DOM nodes with messaging and data must be JSON-serializable.
How can I send my URL?