I am developing a Google chrome extension. My purpose is to send messages from my script1.js to script2.js. Here is what I wrote in my manifest.json:
{
"matches": ["https://www.google.fr/"],
"css": ["styles.css"],
"js": ["script1.js"]
},
{
"matches": ["my_website.html"],
"css": ["styles.css"],
"js": ["script2.js"]
},
Here is what I wrote in script1.js:
chrome.runtime.sendMessage('hello world!!!!!!');
and in script2.js:
chrome.runtime.onMessage.addListener(function(response,sender,sendResponse){
alert(response);
} );
I don't think I'm doing it the right way, I think I've to use the background.js but I don't know how.
Thanks very much in advance.