1

I needed to get deeper into the page so my content script is really just an injector, like this

function injectScript(file) {
    var th = document.getElementsByTagName('body')[0];
    var s = document.createElement('script');
    s.setAttribute('type', 'text/javascript');
    s.setAttribute('src', file);
    th.appendChild(s);
}
injectScript( chrome.extension.getURL('/cs.js') );

Now I need to transport settings (stored in the content scripts local storage) into there as well during runtime. I can do it once no problem by creating another script node and adding the variable declaration and value in its innerHTML. Updating it this way doesn't work as well though.

Currently I have a hidden input added to the page and I write the value there and have the script on the other side periodically check and update the local one. This is just "ugh" and "eww" to me though. Is there any other way I can share the settings object between the two?

user81993
  • 6,167
  • 6
  • 32
  • 64
  • Possible duplicate of [Chrome Extension - Passing object from page to context script](http://stackoverflow.com/questions/26739774/chrome-extension-passing-object-from-page-to-context-script) – cviejo Jan 31 '16 at 21:18

0 Answers0