I'm injecting all my js code to front page, but it needs pictures for ui and stuff, that can be imported only with the help of chrome.extension.getUrl and can be called only from content-script, so I've found tons of advices how to pass data to content page, and nothing of about how pass data back, is it possible at all?
My code now looks like this:
my js code, that will be injected with other code:
var Content = {}; $(document).contentReady = function(content) { Content = content; $(document).ready(function () {/*cool stuff here, that require content*/}); } var event = new CustomEvent('LoadContent'); window.dispatchEvent(event); content-script:
document.querySelector('head').appendChild(jsCode); window.addEventListener("LoadContent", function(evt) { var content = { data: "url(" + chrome.extension.getURL('content.smth') + ")" }; document.contentReady(content); }, false); And, obviously, I get document.contentReady is not a function But declaring function in document was the only(!) advice of about how to pass data back from content-script after about 2 hours of googling.
window). This is a more general question and the dupe should be lifted. Your decision seems to base on an existing answer. Do you agree?