contentscript.js
function createIDArray() { var IDArray = []; IDArray[0] = $('#u_4_0 > span > div').html(); return IDArray; } chrome.runtime.onMessage.addListener( function(request, sender, sendResponse) { console.log("This is being received from popup.js"); if (request.greeting == "hello") console.log(createIDArray()); sendResponse({farewell: "goodbye"}); return true; }); popup.js
$('#9610').click ( function() { chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { chrome.tabs.sendMessage(tabs[0].id, {greeting: "This is data."}, function(response) { console.log(response.farewell); }); }); } ); Not receiving any response between the two scripts. My end goal here is going to be upon clicking a button in the popup, activate a function in the content script.
popup.html
<head> <script type="text/javascript" src="jquery.js"></script> <script src="popup.js"></script> </head> <body> <button id="9610">Copy SRT Data</button> <button id="1691">Paste SRT Data</button> </body> manifest.json
{ "manifest_version": 2, "name": "Task Auto Fill", "description": "This extension shows a Google Image search result for the current page", "version": "1.0", "browser_action": { "default_icon": "icon.png", "default_popup": "popup.html" }, "name": "My extension", "background": { "scripts": ["background.js"] }, "permissions": [ "https://our.intern.facebook.com/", "tabs", "activeTab" ], "content_scripts": [ { "matches": ["http://*/*", "https://*/*"], "js": ["myscript.js"] } ] }