Sql working
This commit is contained in:
12
background.js
Normal file
12
background.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
chrome.runtime.onMessage.addListener(function(request, sender, response) {
|
||||||
|
const xhr = new XMLHttpRequest();
|
||||||
|
const method = request.method ? request.method.toUpperCase() : "GET";
|
||||||
|
xhr.open(method, request.url, true);
|
||||||
|
xhr.onload = () => response(xhr.responseText);
|
||||||
|
xhr.onerror = () => response(xhr.statusText);
|
||||||
|
if (method == "POST") {
|
||||||
|
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
}
|
||||||
|
xhr.send(request.data);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
42
content.js
42
content.js
@@ -1,4 +1,11 @@
|
|||||||
$(document).ready( function() {
|
$(document).ready( function() {
|
||||||
|
sql = window.SQL;
|
||||||
|
loadBinaryFile('grades.db', function(data){
|
||||||
|
var sqldb = new SQL.Database(data);
|
||||||
|
// Database is ready
|
||||||
|
var res = sqldb.exec("SELECT * from agg where dept like '%C S%' and course_nbr like '%314%'");
|
||||||
|
console.log(res[0].values);
|
||||||
|
});
|
||||||
$("table thead th:nth-child(5)").after('<th scope=col>Rating</th>');
|
$("table thead th:nth-child(5)").after('<th scope=col>Rating</th>');
|
||||||
$('table').find('tr').each(function(){
|
$('table').find('tr').each(function(){
|
||||||
var rating;
|
var rating;
|
||||||
@@ -9,17 +16,44 @@ $(document).ready( function() {
|
|||||||
rating = "No Prof :(";
|
rating = "No Prof :(";
|
||||||
} else {
|
} else {
|
||||||
console.log(profurl);
|
console.log(profurl);
|
||||||
|
//getProfessorTID();
|
||||||
//getProfessorFullName(profurl);
|
//getProfessorFullName(profurl);
|
||||||
console.log(profname);
|
// console.log(lastname[0]);
|
||||||
rating = "Hello";
|
rating = "Hello";
|
||||||
}
|
}
|
||||||
$(this).find('td').eq(4).after('<td data-th="Rating"><a href="http://example.com">'+rating+'</a></td>');
|
$(this).find('td').eq(4).after('<td data-th="Rating"><a href="http://example.com">'+rating+'</a></td>');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function loadBinaryFile(path,success) {
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open("GET", chrome.extension.getURL(path), true);
|
||||||
|
xhr.responseType = "arraybuffer";
|
||||||
|
xhr.onload = function() {
|
||||||
|
var data = new Uint8Array(xhr.response);
|
||||||
|
var arr = new Array();
|
||||||
|
for(var i = 0; i != data.length; ++i) arr[i] = String.fromCharCode(data[i]);
|
||||||
|
success(arr.join(""));
|
||||||
|
};
|
||||||
|
xhr.send();
|
||||||
|
};
|
||||||
|
|
||||||
|
// function getProfessorTID(profname) {
|
||||||
|
// var name = profname.split(',');
|
||||||
|
// var lastname = profname[0];
|
||||||
|
// var firstinit = profname[1].substring(1);
|
||||||
|
// console.log(lastname + " "+firstinit);
|
||||||
|
|
||||||
function getProfessorFullName(profurl){
|
// return new Promise((resolve, reject) => {
|
||||||
}
|
// chrome.runtime.sendMessage({
|
||||||
|
// method: "POST",
|
||||||
|
// url: "http://www.ratemyprofessors.com/search.jsp",
|
||||||
|
// data: "queryBy=teacherName&schoolName=university+of+texas+at+austin&query="+profname+"&facetSearch=true"
|
||||||
|
// }, function(response) {
|
||||||
|
// if (response) {
|
||||||
|
// console.log(response);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
//http://www.ratemyprofessors.com/search.jsp?queryBy=teacherName&schoolName=university of texas at austin&query="+url+"&facetSearch=true"
|
|
||||||
|
|||||||
@@ -5,11 +5,19 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"description": "Chrome Extension to show more information on the UT Course catalog",
|
"description": "Chrome Extension to show more information on the UT Course catalog",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
|
"https://utdirect.utexas.edu/apps/registrar/course_schedule/*",
|
||||||
"*://*.ratemyprofessors.com/*"
|
"*://*.ratemyprofessors.com/*"
|
||||||
],
|
],
|
||||||
"content_scripts": [{
|
"content_scripts": [{
|
||||||
"css": ["styles.css"],
|
"css": ["styles.css"],
|
||||||
"js": ["jquery-3.3.1.min.js","content.js"],
|
"js": ["sql.js","jquery-3.3.1.min.js","content.js"],
|
||||||
"matches": ["https://utdirect.utexas.edu/apps/registrar/course_schedule/*"]
|
"matches": ["https://utdirect.utexas.edu/apps/registrar/course_schedule/*"]
|
||||||
}]
|
}],
|
||||||
|
"web_accessible_resources": [
|
||||||
|
"grades.db"],
|
||||||
|
"background": {
|
||||||
|
"scripts": ["background.js"],
|
||||||
|
"persistent": true
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user