I have a chrome extension that calls a content script from a background script to insert HTML into a webpage.
When I call the content script (inject.js), I'd like to pass some parameters from the content script (eventpage.js), but am having some trouble doing so. I also don't want to use a solution that leverages chrome.storage or localstorage.
Manifest.json (relevant parts):
{ "manifest_version": 2, "content_scripts": [ { "matches": ["http://*/*"], "js": ["inject.js"] } ], ... "background": { "scripts": ["eventpage.js",...], "persistent": false }, } Eventpage.js (background):
// Want to add the parameter here chrome.tabs.executeScript(tabId, { file: 'inject.js' }); Inject.js (content):
(function() { // Want to retrieve the parameter passed from eventpage.js here })();