my Chrome extension has two files: content and background scripts. I need to add jQuery to content script from cdn and lodash to background script from cdn too.
In my manifest I tried to add lodash from cdn like this:
"background": {
"scripts": ["background.js", "https://cdn.jsdelivr.net/lodash/4.13.1/lodash.min.js"]
},
"content_security_policy": "script-src 'self' https://cdn.jsdelivr.net; object-src 'self'"
But that didn't help.
My content file is injected to the page from the background file:
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
if (changeInfo.status == 'complete') {
chrome.tabs.insertCSS(null, {file: "mainStyles.css"});
chrome.tabs.executeScript(null, {
code: 'var config = ' + JSON.stringify(config)
}, function() {
chrome.tabs.executeScript(null, { file: "https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js" }, function() {
chrome.tabs.executeScript(null, { file: "content.js" })
});
});
}
});
And as you can see I tried to include jQuery from cdn but this way it's not included either.
Maybe someone knows the way how to do this?
Many thanks in advance!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…