How do I send some stored data to a script (declared in web_acessible_resources) that I want to inject into a webpage? I've tried to send message from my background script but chrome.extension is not available for use.
manifest.json:
{
"manifest_version": 2,
"name": "Tool",
"version": "0.0",
"devtools_page": "devtools.html",
"content_scripts": [{
"matches": ["<all_urls>"],
"js": ["contentscript.js"]
}],
"background": {
"scripts": ["background.js"]
},
"browser_action": {
"default_icon": "icon.jpg"
},
"web_accessible_resources": [
"config.js",
"script.js",
],
"permissions": [
"storage"
]
}
The config.js
contain js configuration to be used by script.js
. So in my contentscript.js
I have:
var a = document.createElement("script");
a.src = chrome.extension.getURL("config.js");
(document.heade || document.documentElement).appendChild(a);
var s = document.createElement("script");
s.src = chrome.extension.getURL("script.js");
(document.head || document.documentElement).appendChild(s);
What do i need to do in my background.js
so that the following is possible inside my config.js
?
var myConfig = <some dictionary/json file generated from background.js>