I'm trying to write a simple extension to decode a URL that´s given within the body of a page. I've got this contentscript:
function getText(){
var text = document.body.innerText;
return text;
}
var Text = getText();
console.log(Text);
chrome.runtime.sendMessage({ Text: Text});
and this for my popup:
function decodeURL(Encoded) {
var Decoded = decodeURIComponent(Encoded);
return Decoded;
}
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse){
localStorage["Text"] = request.Text;
console.log(localStorage["Text"]);
}
);
var List = localStorage["Text"].split(" ");
var URL = List[List.length - 1];
document.write("<a href=");
document.write(URL);
document.write(">");
document.write("Log In");
document.write("</a>");
Now my content script get´s the text and prints it to the console but the popup script doesn´t seem to be able to access it. I know this has been asked many times but none of the other Threads contained anything I could get to work.