I am making a chrome extension that inserts multiple css and javascript files. I was previously using content scripts but now I want to insert the script and css onClick. I tried just injecting my main script script.js in my background and keeping the rest of my css files associated with this script in my content script section in manifest. However, when I tried this in my extension it did not work. Should I execute and insert all my content and css in my background and if so in what order because one script or css has to be inserted or executed inside another.
I looked at " Injecting multiple scripts through executeScript in Google Chrome" however I don't know if their is a easier way in my situation and I do not know if that articles applies to css.
Here's part of my manifest:
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*"],
"css": ["styles.css", "tipped.css"],
"js": ["jquery-1.9.1.js", "jquery-highlight1.js", "spinners.min.js", "tipped.js","script.js"],
"run_at": "document_end"
}
],
"permissions":[
"activeTab"
],
Here is my background script:
chrome.browserAction.onClicked.addListener(function(activeTab) {
chrome.tabs.executeScript(null, {file: "script.js"});
});