1- import { isExtensionPage , isExtensionPopup } from ' @chrome-extension-toolkit' ;
1+ import { isExtensionPage , isExtensionPopup } from " @chrome-extension-toolkit" ;
22
33/**
44 * An enum that represents the different types of pages that we support
55 * a given url/page can correspond to many of these enum values
66 */
77export const SiteSupport = {
8- COURSE_CATALOG_LIST : ' COURSE_CATALOG_LIST' ,
9- COURSE_CATALOG_DETAILS : ' COURSE_CATALOG_DETAILS' ,
10- UT_PLANNER : ' UT_PLANNER' ,
11- WAITLIST : ' WAITLIST' ,
12- EXTENSION_POPUP : ' EXTENSION_POPUP' ,
13- MY_CALENDAR : ' MY_CALENDAR' ,
14- REPORT_ISSUE : ' REPORT_ISSUE' ,
15- MY_UT : ' MY_UT' ,
16- COURSE_CATALOG_SEARCH : ' COURSE_CATALOG_SEARCH' ,
17- CLASSLIST : ' CLASSLIST' ,
18- COURSE_CATALOG_KWS : ' COURSE_CATALOG_KWS' ,
8+ COURSE_CATALOG_LIST : " COURSE_CATALOG_LIST" ,
9+ COURSE_CATALOG_DETAILS : " COURSE_CATALOG_DETAILS" ,
10+ UT_PLANNER : " UT_PLANNER" ,
11+ WAITLIST : " WAITLIST" ,
12+ EXTENSION_POPUP : " EXTENSION_POPUP" ,
13+ MY_CALENDAR : " MY_CALENDAR" ,
14+ REPORT_ISSUE : " REPORT_ISSUE" ,
15+ MY_UT : " MY_UT" ,
16+ COURSE_CATALOG_SEARCH : " COURSE_CATALOG_SEARCH" ,
17+ CLASSLIST : " CLASSLIST" ,
18+ COURSE_CATALOG_KWS : " COURSE_CATALOG_KWS" ,
1919} as const ;
2020
2121/**
@@ -34,31 +34,43 @@ export default function getSiteSupport(url: string): SiteSupportType | null {
3434 if ( isExtensionPopup ( ) ) {
3535 return SiteSupport . EXTENSION_POPUP ;
3636 }
37- if ( isExtensionPage ( ' my_calendar.html' ) ) {
37+ if ( isExtensionPage ( " my_calendar.html" ) ) {
3838 return SiteSupport . MY_CALENDAR ;
3939 }
40- if ( url . includes ( ' utexas.collegescheduler.com' ) ) {
40+ if ( url . includes ( " utexas.collegescheduler.com" ) ) {
4141 return SiteSupport . UT_PLANNER ;
4242 }
43- if ( url . includes ( ' utdirect.utexas.edu/apps/registrar/course_schedule' ) ) {
44- if ( url . includes ( ' kws_results' ) ) {
43+ if ( url . includes ( " utdirect.utexas.edu/apps/registrar/course_schedule" ) ) {
44+ if ( url . includes ( " kws_results" ) ) {
4545 return SiteSupport . COURSE_CATALOG_KWS ;
4646 }
47- if ( url . includes ( ' results' ) ) {
47+ if ( url . includes ( " results" ) ) {
4848 return SiteSupport . COURSE_CATALOG_LIST ;
4949 }
50- if ( document . querySelector ( ' #details' ) ) {
50+ if ( document . querySelector ( " #details" ) ) {
5151 return SiteSupport . COURSE_CATALOG_DETAILS ;
5252 }
5353 return SiteSupport . COURSE_CATALOG_SEARCH ;
5454 }
55- if ( url . includes ( 'utdirect.utexas.edu' ) && ( url . includes ( 'waitlist' ) || url . includes ( 'classlist' ) ) ) {
55+ if (
56+ url . includes ( "utdirect.utexas.edu" ) &&
57+ ( url . includes ( "waitlist" ) || url . includes ( "classlist" ) )
58+ ) {
5659 return SiteSupport . WAITLIST ;
5760 }
58- if ( url . includes ( 'my.utexas.edu/student/student/index' ) || url . includes ( 'my.utexas.edu/student/' ) ) {
59- return SiteSupport . MY_UT ;
61+ try {
62+ const parsed = new URL ( url ) ;
63+ if (
64+ parsed . hostname === "my.utexas.edu" &&
65+ ( parsed . pathname === "/student" ||
66+ parsed . pathname . startsWith ( "/student/" ) )
67+ ) {
68+ return SiteSupport . MY_UT ;
69+ }
70+ } catch {
71+ // Ignore malformed URLs and continue with other matchers.
6072 }
61- if ( url . includes ( ' registration/classlist.WBX' ) ) {
73+ if ( url . includes ( " registration/classlist.WBX" ) ) {
6274 return SiteSupport . CLASSLIST ;
6375 }
6476 return null ;
0 commit comments