bunch of misc changes
This commit is contained in:
@@ -17,6 +17,7 @@ const HOT_RELOADING_WHITELIST = [
|
|||||||
'reddit.com',
|
'reddit.com',
|
||||||
'gmail.com',
|
'gmail.com',
|
||||||
'photopea.com',
|
'photopea.com',
|
||||||
|
'chat.openai.com',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,3 +40,5 @@ export async function hotReloadTab(): Promise<void> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import io from 'socket.io-client';
|
import io from 'socket.io-client';
|
||||||
import { bMessenger } from 'src/shared/messages';
|
import { background } from 'src/shared/messages';
|
||||||
|
|
||||||
const socket = io('http://localhost:9090');
|
const socket = io('http://localhost:9090');
|
||||||
let reBuilding = false;
|
let reBuilding = false;
|
||||||
@@ -27,7 +27,7 @@ socket.on('reload', async () => {
|
|||||||
console.log('%c[hot-reloading] reloading...', 'color:white; background-color: orange;');
|
console.log('%c[hot-reloading] reloading...', 'color:white; background-color: orange;');
|
||||||
chrome.tabs.query({ active: true, currentWindow: true }, tabs => {
|
chrome.tabs.query({ active: true, currentWindow: true }, tabs => {
|
||||||
if (tabs?.[0]?.id) {
|
if (tabs?.[0]?.id) {
|
||||||
bMessenger.reloadExtension();
|
background.reloadExtension();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ export type BACKGROUND_MESSAGES = BrowserActionMessages &
|
|||||||
/**
|
/**
|
||||||
* A utility object that can be used to send type-safe messages to the background script
|
* A utility object that can be used to send type-safe messages to the background script
|
||||||
*/
|
*/
|
||||||
export const bMessenger = createMessenger<BACKGROUND_MESSAGES>('background');
|
export const background = createMessenger<BACKGROUND_MESSAGES>('background');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A utility object that can be used to send type-safe messages to specific tabs
|
* A utility object that can be used to send type-safe messages to specific tabs
|
||||||
*/
|
*/
|
||||||
export const tabMessenger = createMessenger<TAB_MESSAGES>('tab');
|
export const tabs = createMessenger<TAB_MESSAGES>('tab');
|
||||||
|
|||||||
@@ -24,4 +24,10 @@ export const DevStore = createLocalStore<IDevStore>({
|
|||||||
reloadTabId: undefined,
|
reloadTabId: undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
debugStore({ devStore: DevStore });
|
debugStore({ devStore: DevStore });
|
||||||
|
|||||||
@@ -15,4 +15,6 @@ export const ExtensionStore = createLocalStore<IExtensionStore>({
|
|||||||
lastUpdate: Date.now(),
|
lastUpdate: Date.now(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
debugStore({ ExtensionStore });
|
debugStore({ ExtensionStore });
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ interface IOptionsStore {
|
|||||||
shouldHighlightConflicts: boolean;
|
shouldHighlightConflicts: boolean;
|
||||||
/** whether we should automatically scroll to load more courses on the course schedule page (without having to click next) */
|
/** whether we should automatically scroll to load more courses on the course schedule page (without having to click next) */
|
||||||
shouldScrollToLoad: boolean;
|
shouldScrollToLoad: boolean;
|
||||||
|
|
||||||
|
url: URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const OptionsStore = createSyncStore<IOptionsStore>({
|
export const OptionsStore = createSyncStore<IOptionsStore>({
|
||||||
@@ -15,4 +17,6 @@ export const OptionsStore = createSyncStore<IOptionsStore>({
|
|||||||
shouldScrollToLoad: true,
|
shouldScrollToLoad: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Clothing retailer right
|
||||||
|
|
||||||
debugStore({ OptionsStore });
|
debugStore({ OptionsStore });
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { bMessenger } from 'src/shared/messages';
|
import { background } from 'src/shared/messages';
|
||||||
import useSchedules from '../hooks/useSchedules';
|
import useSchedules from '../hooks/useSchedules';
|
||||||
import { Button } from './common/Button/Button';
|
import { Button } from './common/Button/Button';
|
||||||
import ExtensionRoot from './common/ExtensionRoot/ExtensionRoot';
|
import ExtensionRoot from './common/ExtensionRoot/ExtensionRoot';
|
||||||
|
|
||||||
const { clearCourses } = bMessenger;
|
|
||||||
export default function PopupMain() {
|
export default function PopupMain() {
|
||||||
const [activeSchedule, schedules] = useSchedules();
|
const [activeSchedule, schedules] = useSchedules();
|
||||||
|
|
||||||
@@ -15,7 +14,7 @@ export default function PopupMain() {
|
|||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (!activeSchedule) return;
|
if (!activeSchedule) return;
|
||||||
clearCourses({ scheduleName: activeSchedule?.name });
|
background.clearCourses({ scheduleName: activeSchedule?.name });
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Clear Courses
|
Clear Courses
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import React, { PropsWithChildren } from 'react';
|
import React, { PropsWithChildren } from 'react';
|
||||||
import { bMessenger } from 'src/shared/messages';
|
import { background } from 'src/shared/messages';
|
||||||
import Text, { TextProps } from '../Text/Text';
|
import Text, { TextProps } from '../Text/Text';
|
||||||
import styles from './Link.module.scss';
|
import styles from './Link.module.scss';
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ export default function Link(props: PropsWithChildren<Props>) {
|
|||||||
const { url } = props;
|
const { url } = props;
|
||||||
|
|
||||||
if (url && !props.onClick) {
|
if (url && !props.onClick) {
|
||||||
passedProps.onClick = () => bMessenger.openNewTab({ url });
|
passedProps.onClick = () => background.openNewTab({ url });
|
||||||
}
|
}
|
||||||
const isDisabled = props.disabled || (!url && !props.onClick);
|
const isDisabled = props.disabled || (!url && !props.onClick);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { bMessenger } from 'src/shared/messages';
|
import { background } from 'src/shared/messages';
|
||||||
import { Course } from 'src/shared/types/Course';
|
import { Course } from 'src/shared/types/Course';
|
||||||
import { UserSchedule } from 'src/shared/types/UserSchedule';
|
import { UserSchedule } from 'src/shared/types/UserSchedule';
|
||||||
import { Button } from 'src/views/components/common/Button/Button';
|
import { Button } from 'src/views/components/common/Button/Button';
|
||||||
@@ -13,7 +13,7 @@ type Props = {
|
|||||||
course: Course;
|
course: Course;
|
||||||
};
|
};
|
||||||
|
|
||||||
const { openNewTab, addCourse, removeCourse } = bMessenger;
|
const { openNewTab, addCourse, removeCourse } = background;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This component displays the buttons for the course info popup, that allow the user to either
|
* This component displays the buttons for the course info popup, that allow the user to either
|
||||||
|
|||||||
20
src/views/hooks/useVersion.ts
Normal file
20
src/views/hooks/useVersion.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import { Serialized } from 'chrome-extension-toolkit';
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { ExtensionStore } from 'src/shared/storage/ExtensionStore';
|
||||||
|
|
||||||
|
export default function useVersion(): string {
|
||||||
|
const [version, setVersion] = useState<string>('');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const listener = ExtensionStore.listen('version', ({ newValue }) => {
|
||||||
|
setVersion(newValue);
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
ExtensionStore.removeListener(listener);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { background } from 'src/shared/messages';
|
||||||
import render from './lib/react';
|
import render from './lib/react';
|
||||||
|
|
||||||
import { ContextInvalidated, createShadowDOM, isExtensionPopup, onContextInvalidated } from 'chrome-extension-toolkit';
|
import { ContextInvalidated, createShadowDOM, isExtensionPopup, onContextInvalidated } from 'chrome-extension-toolkit';
|
||||||
@@ -14,6 +15,11 @@ if (!support) {
|
|||||||
throw new Error('UT Registration Plus does not support this page, even though it should...');
|
throw new Error('UT Registration Plus does not support this page, even though it should...');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if we are in an iframe, throw an error
|
||||||
|
if (window.self !== window.top) {
|
||||||
|
throw new Error('inside an iframe');
|
||||||
|
}
|
||||||
|
|
||||||
if (support === SiteSupport.EXTENSION_POPUP) {
|
if (support === SiteSupport.EXTENSION_POPUP) {
|
||||||
render(<PopupMain />, document.getElementById('root'));
|
render(<PopupMain />, document.getElementById('root'));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user