Reputation: 173
I'm trying to create a chrome extension that pops up a small input when a user highlights text on the page (similar to Medium's tweet on text highlight feature).
I'm progressing but would find it much easier to use jQuery (rather than vanilla JS and XHRs).
I've seen a few posts about requiring jQuery in the manifest, and I've tried it many different ways without success.
I have a manifest(below), a contentscript.js and dropdown.js(the file I want to inject onto the page).
{
"name": "na",
"version": "1.0",
"manifest_version": 2,
"description": "na",
"homepage_url": "na",
"content_scripts": [{
"js": ["jquery.js", "contentscript.js"],
"matches": ["https://github.com/*"]
}],
"web_accessible_resources": ["jquery.js","dropdown.js"]
}
Any assistance would be much appreciated!
Upvotes: 1
Views: 3297
Reputation: 307
Assuming that you have jquery.js in the main folder, then the way you have your manifest written should work. I suspect that either you do not have the jQuery file in the main folder (maybe it's in a scripts folder, in which case you should be referencing the folder location: scripts/jquery.js, for example) or that the name is incorrect (maybe it's jquery.min.js).
If you don't have jQuery downloaded, I would recommend referencing the Google hosted library in your manifest (in the same location you currently have it indicated)
{
"name": "na",
"version": "1.0",
"manifest_version": 2,
"description": "na",
"homepage_url": "na",
"content_scripts": [{
"js": ["https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js", "contentscript.js"],
"matches": ["https://github.com/*"]
}],
"web_accessible_resources": ["dropdown.js"]
}
Upvotes: 2