Reputation: 2409
I am trying to create a chrome extension that interacts with and changes the content of my University's Job Board in order to add ratings from glassdoor. This is my first extension, so please forgive any obvious errors.
manifest.json:
{
"manifest_version": 2,
"name": "My Cool Extension",
"version": "0.1",
"background": {
"scripts": ["background.js"]
},
"content_scripts": [
{
"matches": [
"https://lehigh-csm.symplicity.com/students/*",
"https://api.glassdoor.com/api/*"
],
"js": ["jquery.min.js", "content.js"]
}
],
}
content.js:
var jsonFile = "https://api.glassdoor.com/api/api.htm?t.p=51863&t.k=kPRnCOceJPO&userip=0.0.0.0&useragent=&format=json&v=1&action=employers&q=test";
$.getJSON(jsonFile, function(data) {
var items = [];
console.log(data);
});
However I am getting the error: Uncaught ReferenceError: $ is not defined
Any clue what I could be doing wrong? I tried browsing some of the similar questions but cannot get their solutions to work.
Thanks!
Upvotes: 1
Views: 3491
Reputation: 81
Well the answer is obvious, you haven't imported a jQuery file. How to do this is beyond my knowledge unless you're putting it into a web page but you can download the jQuery files here: https://jquery.org/
If this isn't possible to put jQuery into an extension then try changing your code to just plain JavaScript. All jQuery does is it makes JavaScript shorter, more simple, or easier to use. You can translate jQuery to JavaScript with a few quick Google searches...
This MAY help. I dunno. http://api.jquery.com/jquery.getjson/
Edit: Load JQuery into a Chrome extension?
How to use jQuery in chrome extension?
Google Chrome Extensions: How to include jQuery in programmatically injected content script?
Try these
Upvotes: 2