diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 114c16d..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "env": { - "browser": true, - "commonjs": true, - "es2021": true - }, - "extends": "eslint:recommended", - "overrides": [ - ], - "parserOptions": { - "ecmaVersion": "latest" - }, - "rules": { - } -} diff --git a/.gitignore b/.gitignore index 76efb07..25f452e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules +test .vscode diff --git a/deprecatedbackground.js b/deprecatedbackground.js deleted file mode 100644 index 9af86db..0000000 --- a/deprecatedbackground.js +++ /dev/null @@ -1,29 +0,0 @@ -const ratings = require('@mtucourses/rate-my-professors').default; -console.log("background.js loaded"); - -async function getAvgRating(profName) { - - const basicProfInfo = await ratings.searchTeacher(profName, 'U2Nob29sLTE0OTU='); - - console.log(basicProfInfo); - if (!basicProfInfo || basicProfInfo.length === 0) { - return { error: 'Professor not found' }; - } - - const id = basicProfInfo[0].id; - const profInfo = await ratings.getTeacher(id); - const avgRating = profInfo.avgRating; - console.log(avgRating); - - return avgRating; -} - -chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { - console.log('received message from content script:', request); - console.log(request.professorName); - - getAvgRating(request.professorName).then(response => { - sendResponse(response); - }); - return true; -}); diff --git a/jstest.js b/jstest.js deleted file mode 100644 index ff3fc8f..0000000 --- a/jstest.js +++ /dev/null @@ -1,95 +0,0 @@ -const {GraphQLClient, gql} = require('graphql-request'); - -const searchTeacherQuery = gql` -query NewSearchTeachersQuery($text: String!, $schoolID: ID!) -{ - newSearch { - teachers(query: {text: $text, schoolID: $schoolID}) { - edges { - cursor - node { - id - firstName - lastName - school { - name - id - } - } - } - } - } -} -`; - - -const getTeacherQuery = gql` -query TeacherRatingsPageQuery( - $id: ID! -) { - node(id: $id) { - ... on Teacher { - id - firstName - lastName - school { - name - id - city - state - } - avgDifficulty - avgRating - department - numRatings - legacyId - wouldTakeAgainPercent - } - id - } -} -`; - -const AUTH_TOKEN = 'dGVzdDp0ZXN0'; - -const client = new GraphQLClient('https://www.ratemyprofessors.com/graphql', { - headers: { - authorization: `Basic ${AUTH_TOKEN}` - } -}); - -const searchTeacher = async (name, schoolID) => { - const response = await client.request(searchTeacherQuery, { - text: name, - schoolID - }); - - if (response.newSearch.teachers === null) { - return []; - } - - return response.newSearch.teachers.edges.map((edge) => edge.node); -}; - -const getTeacher = async (id) => { - const response = await client.request(getTeacherQuery, {id}); - - return response.node; -}; - -async function main() { - const profName = 'Hossein Kassiri'; - console.log(profName); - const teachers = await searchTeacher(profName, 'U2Nob29sLTE0OTU='); - console.log(teachers); - const teacherID = teachers[0].id; - const teacher = await getTeacher(teacherID); - const avgRating = teacher.avgRating; - console.log(teacher); - console.log(avgRating); -} - -main().catch((error) => { - console.error(error); - }); - \ No newline at end of file diff --git a/package.json b/package.json index 712ef1f..526ce79 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,6 @@ { "dependencies": { - "@apollo/client": "^3.7.3", - "@mtucourses/rate-my-professors": "^2.2.0", + "graphql": "^16.6.0", "graphql-request": "^5.1.0" }, - "devDependencies": { - "eslint": "^8.30.0", - "webpack": "^5.75.0", - "webpack-cli": "^5.0.1" - } -} diff --git a/test.js b/test.js deleted file mode 100644 index 12e25d7..0000000 --- a/test.js +++ /dev/null @@ -1,20 +0,0 @@ -const ratings = require('@mtucourses/rate-my-professors').default; - -(async () => { - - const profName = 'Hossein Kassiri'; - const basicProfInfo = await ratings.searchTeacher(profName, 'U2Nob29sLTE0OTU='); - - const id = basicProfInfo[0].id; - console.log(basicProfInfo); - //console.log(id); - - // get the profs avg rating - const profInfo = await ratings.getTeacher(id); - const avgRating = profInfo.avgRating; - - //console.log(profInfo); - console.log(avgRating); - console.log("https://www.ratemyprofessors.com/professor?tid=" + profInfo.legacyId); - -})();