I have a chrome extension that uses both content script and a background script. Those scripts are also communicating with each other using chrome.runtime.sendMessage.
But when I add both scripts in manifest.json, only the background script seems to be working. Removing the background script from the manifest solves the problem and the content script get loaded.
My manifest.json
"manifest_version": 2,
...
"permissions": [
"contentSettings",
"notifications",
"storage",
"https://*.soundcloud.com/*",
"https://soundcloud.com/*"
],
"content_scripts": [
{
"matches": [
"https://*.soundcloud.com/*",
"https://soundcloud.com/*"
],
"js": [
"js/jquery/jquery.min.js",
"js/arrive/arrive.min.js",
"src/inject/inject.js"
]
}
],
"background": {
"scripts": [
"src/background/background.js"
],
"persistent": false
}
}
My injected content script (works on its own):
chrome.runtime.sendMessage(response, function(response) {
console.log("FROM BACKGROUND: " + response);
});
My background script:
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
var options = {
type: "image",
title: "Track now playing!",
message: response.artist + " - " + response.title,
imageUrl: response.artwork,
isClickable: false
};
chrome.notifications.create("", options, function(e) {
sendResponse("Notification was send!");
});
});
chrome.runtimedoesn't need permissions. Could you post minimal content and background scripts that show something isn't working? - Teepeemm