From f3bf746c6e401ee5a04ff9faa3c45202a07958fc Mon Sep 17 00:00:00 2001 From: Sriram Hariharan Date: Tue, 7 Mar 2023 22:17:17 -0600 Subject: [PATCH] textbook button, properly scraping the semester (year and season) from the url" --- src/shared/types/Course.ts | 4 +- .../CourseButtons/CourseButtons.tsx | 10 +++- src/views/lib/CourseCatalogScraper.ts | 55 +++++++++++++------ todo.md | 8 +-- 4 files changed, 55 insertions(+), 22 deletions(-) diff --git a/src/shared/types/Course.ts b/src/shared/types/Course.ts index 2fdb42b1..3741fdf9 100644 --- a/src/shared/types/Course.ts +++ b/src/shared/types/Course.ts @@ -25,7 +25,9 @@ export type Semester = { /** The year that the semester is in */ year: number; /** The season that the semester is in (Fall, Spring, Summer) */ - season: string; + season: 'Fall' | 'Spring' | 'Summer'; + /** UT's code for the semester */ + code: string; }; /** diff --git a/src/views/components/injected/CoursePopup/CourseHeader/CourseButtons/CourseButtons.tsx b/src/views/components/injected/CoursePopup/CourseHeader/CourseButtons/CourseButtons.tsx index de54ac80..3d3ad3f1 100644 --- a/src/views/components/injected/CoursePopup/CourseHeader/CourseButtons/CourseButtons.tsx +++ b/src/views/components/injected/CoursePopup/CourseHeader/CourseButtons/CourseButtons.tsx @@ -53,6 +53,14 @@ export default function CourseButtons({ course }: Props) { openNewTab({ url: url.toString() }); }; + const openTextbookURL = () => { + const { department, number, semester, uniqueId } = course; + const url = new URL('https://www.universitycoop.com/adoption-search-results'); + url.searchParams.append('sn', `${semester.code}__${department}__${number}__${uniqueId}`); + + openNewTab({ url: url.toString() }); + }; + return ( -