-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from UTDNebula/feat/v1
Feat/v1
- Loading branch information
Showing
30 changed files
with
823 additions
and
410 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
"name": "sk.edge", | ||
"displayName": "sk.edge", | ||
"version": "0.0.1", | ||
"description": "the all-in-one registration tool by students, for students", | ||
"description": "your registration assistant by students, for students", | ||
"author": "Nebula Labs", | ||
"packageManager": "[email protected]", | ||
"scripts": { | ||
|
@@ -12,13 +12,15 @@ | |
}, | ||
"dependencies": { | ||
"@plasmohq/messaging": "^0.1.6", | ||
"@plasmohq/storage": "^1.3.1", | ||
"apexcharts": "^3.37.1", | ||
"next": "^13.1.5", | ||
"plasmo": "^0.67.3", | ||
"react": "18.2.0", | ||
"react-apexcharts": "^1.4.0", | ||
"react-dom": "18.2.0", | ||
"react-icons": "^4.7.1", | ||
"react-loader-spinner": "^5.3.4", | ||
"react-router-dom": "^6.8.2" | ||
}, | ||
"devDependencies": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { scrapeCourseData, CourseHeader } from "~content"; | ||
import { Storage } from "@plasmohq/storage"; | ||
|
||
export interface ShowCourseTabPayload { | ||
header: CourseHeader; | ||
professors: string[]; | ||
} | ||
|
||
// State vars | ||
let courseTabId: number = null; | ||
let scrapedCourseData: ShowCourseTabPayload = null; | ||
|
||
// for persistent state | ||
const storage = new Storage(); | ||
|
||
/** Injects the content script if we hit a course page */ | ||
chrome.webNavigation.onHistoryStateUpdated.addListener(details => { | ||
if (/^.*:\/\/utdallas\.collegescheduler\.com\/terms\/.*\/courses\/.+$/.test( | ||
details.url | ||
)) | ||
{ | ||
chrome.scripting.executeScript({ | ||
target: { | ||
tabId: details.tabId, | ||
}, | ||
world: "MAIN", | ||
// content script injection only works reliably on the prod packaged extension | ||
// b/c of the plasmo dev server connections | ||
func: scrapeCourseData, | ||
}, async function (resolve) { | ||
if (resolve && resolve[0] && resolve[0].result) { | ||
const result: ShowCourseTabPayload = resolve[0].result; | ||
scrapedCourseData = result; | ||
await storage.set("scrapedCourseData", scrapedCourseData) | ||
}; | ||
}); | ||
chrome.action.setBadgeText({text: "!"}); | ||
chrome.action.setBadgeBackgroundColor({color: 'green'}); | ||
courseTabId = details.tabId | ||
storage.set("courseTabId", courseTabId) | ||
storage.set("courseTabUrl", details.url) | ||
} else { | ||
chrome.action.setBadgeText({text: ""}); | ||
} | ||
}); | ||
|
||
/** Sets the icon to be active if we're on a course tab */ | ||
chrome.tabs.onActivated.addListener(async details => { | ||
const cachedTabUrl: string = await storage.get("courseTabUrl") | ||
const currentTabUrl: string = (await getCurrentTab()).url | ||
if (cachedTabUrl === currentTabUrl) { | ||
chrome.action.setBadgeText({text: "!"}); | ||
chrome.action.setBadgeBackgroundColor({color: 'green'}); | ||
} else { | ||
chrome.action.setBadgeText({text: ""}); | ||
} | ||
}); | ||
|
||
export async function getScrapedCourseData() { | ||
const cachedTabUrl: string = await storage.get("courseTabUrl") | ||
const currentTabUrl: string = (await getCurrentTab()).url | ||
if (cachedTabUrl === currentTabUrl) { | ||
return await storage.get("scrapedCourseData"); | ||
} | ||
return null | ||
} | ||
|
||
async function getCurrentTab() { | ||
let queryOptions = { active: true, lastFocusedWindow: true }; | ||
// `tab` will either be a `tabs.Tab` instance or `undefined`. | ||
let [tab] = await chrome.tabs.query(queryOptions); | ||
return tab; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
import type { PlasmoMessaging } from "@plasmohq/messaging" | ||
import {getScrapedCourseData} from "../index"; | ||
import { getScrapedCourseData } from "../../background"; | ||
|
||
const handler: PlasmoMessaging.MessageHandler = async (req, res) => { | ||
const data = getScrapedCourseData(); | ||
|
||
res.send({ | ||
data | ||
}) | ||
const data = await getScrapedCourseData(); | ||
res.send(data) | ||
} | ||
|
||
export default handler |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import nebulaLogo from "data-base64:../../assets/nebula-logo.svg" | ||
|
||
export const Footer = () => { | ||
|
||
const navigateToNebula = (): void => { | ||
window.open("https://www.utdnebula.com/", "_blank") | ||
} | ||
|
||
return ( | ||
<div className="rounded-b-2xl p-2 bg-gray-light -mb-4 -ml-4 -mr-4"> | ||
<div className="flex items-center justify-center"> | ||
<h4 className="pr-2">Powered by Nebula Labs</h4> | ||
<img onClick={navigateToNebula} src={nebulaLogo} alt="Nebula Labs Logo" className="w-[25px] h-[25px] hover:cursor-pointer"></img> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Card } from "./Card" | ||
import { Footer } from "./Footer" | ||
import skedgeLogo from "data-base64:../../assets/icon.png" | ||
|
||
const SURVEY_URL = "https://docs.google.com/forms/d/e/1FAIpQLScGIXzlYgsx1SxHYTTCwRaMNVYNRe6I67RingPRVzcT1tLwSg/viewform?usp=sf_link" | ||
const GALAXY_URL = "https://www.utdallas.edu/galaxy/" | ||
|
||
export const Landing = () => { | ||
|
||
const navigativeToScheduler = (): void => { | ||
window.open(GALAXY_URL, "_blank") | ||
} | ||
|
||
const navigateToSurvey = (): void => { | ||
window.open(SURVEY_URL, "_blank") | ||
} | ||
|
||
return( | ||
<Card> | ||
<div className="h-auto"> | ||
<h1>Welcome to sk.edge 👋</h1> | ||
<h6 className="my-2">your registration assistant by students, for students</h6> | ||
<img src={skedgeLogo} alt="" className="w-[100px] h-[100px] float-right" /> | ||
<p className="mb-2">Log into <b>Schedule Planner</b> and click <b>Options</b> on a course to get started!</p> | ||
<p className="mb-2">Got feedback? Let us know <button className="text-purple-dark" onClick={navigateToSurvey}>here</button>!</p> | ||
<button onClick={navigativeToScheduler} className="text-center flex py-2 px-4 mb-4 bg-blue-dark hover:bg-blue-dark-hover rounded-lg transition duration-250 ease-in-out"> | ||
<h3 className="text-center text-white">To Galaxy!</h3> | ||
</button> | ||
<Footer /> | ||
</div> | ||
</Card> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Rings } from "react-loader-spinner" | ||
|
||
export const Loading = () => { | ||
return ( | ||
<div className="h-64 flex justify-center items-center"> | ||
<Rings | ||
height="80" | ||
width="80" | ||
color="#1C2A6D" | ||
radius="6" | ||
wrapperStyle={{}} | ||
wrapperClass="block mx-auto w-[80px] h-[80px]" | ||
visible={true} | ||
ariaLabel="rings-loading" | ||
/> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import { useState } from "react"; | ||
import Chart from "react-apexcharts" | ||
import { miniGradeChartOptions } from "~utils/styling"; | ||
import type { GradeDistribution } from "./ProfileGrades" | ||
|
||
export const MiniGrades = ({ gradeDistributionData } : { gradeDistributionData: GradeDistribution }) => { | ||
miniGradeChartOptions.title.text = gradeDistributionData.name; | ||
const config = JSON.parse(JSON.stringify(miniGradeChartOptions)) | ||
config.title.text = gradeDistributionData.name; | ||
return ( | ||
<> | ||
<Chart options={miniGradeChartOptions} series={gradeDistributionData.series} type="bar" height={124}></Chart> | ||
<Chart options={config} series={gradeDistributionData.series} type="bar" height={124}></Chart> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.