问题
EDIT - problem solved. I just not reloaded extension properly after changing my manifest. Shame on me.
I'm trying to connect some libs like JQuery to my background.js in chrome extension. Well, I found lots of tips how to do it, but I receive an error. My manifest.json:
{
"manifest_version": 2,
"name": "Chrome WM",
"version": "0.1",
"content_scripts": [{
"matches": ["http://*/*","https://*/*"],
"js": [
"s/jquery-1.11.1.min.js", "s/jquery.soap.js"
]
}],
"background": {
"scripts": ["s/jquery-1.11.1.min.js", "s/jquery.soap.js", "background.js"],
"persistent": false
},
"permissions": [
"tabs",
"activeTab",
"http://192.168.10.150:801/*"
]
}
I probably don't need "content_scripts" section, but just in case.
My background.js:
function siteChanged(activeInfo) {
if (jQuery) {
console.log("Jquery on");
} else {
console.log("Jquery off");
}
// Lots of things here
}
chrome.tabs.onActivated.addListener(siteChanged);
Okay, if I remove this "if (JQuery)" thing whole script works fine, but if not I'm receive such error when event occured:
Error in event handler for tabs.onActivated: ReferenceError: jQuery is not defined
at siteChanged (chrome-extension://flhbfgingimkoknegkcnchnhjdmnhcji/background.js:6:6)
There IS jquery-1.11.1.min.js script in s folder relatively background.js file, and if I create html page beside this background script, grab this jquery-1.11.1.min.js and check if it connected properly - all fine.
What I doing wrong?
来源:https://stackoverflow.com/questions/27542186/connect-external-js-lib-to-chrome-event-page