mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
Add settings for custom backgrounds and allow users to set image and video backgrounds
This commit is contained in:
+21
-3
@@ -15,6 +15,7 @@ browser.storage.local.get([ "telemetry" ]).then((telemetry) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
import { onError } from './seqta/utils/onError';
|
import { onError } from './seqta/utils/onError';
|
||||||
|
import { SettingsState } from "./types/storage";
|
||||||
export const openDB = () => {
|
export const openDB = () => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const request = indexedDB.open('MyDatabase', 1);
|
const request = indexedDB.open('MyDatabase', 1);
|
||||||
@@ -141,16 +142,33 @@ function GetNews(sendResponse: any, url: string) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const DefaultValues: any = {
|
const DefaultValues: SettingsState = {
|
||||||
onoff: true,
|
onoff: true,
|
||||||
animatedbk: true,
|
animatedbk: true,
|
||||||
telemetry: false,
|
telemetry: false,
|
||||||
bksliderinput: 50,
|
bksliderinput: "50",
|
||||||
transparencyEffects: false,
|
transparencyEffects: false,
|
||||||
lessonalert: true,
|
lessonalert: true,
|
||||||
notificationcollector: true,
|
notificationcollector: true,
|
||||||
defaultmenuorder: [],
|
defaultmenuorder: [],
|
||||||
menuitems: {},
|
menuitems: {
|
||||||
|
assessments: { toggle: true },
|
||||||
|
courses: { toggle: true },
|
||||||
|
dashboard: { toggle: true },
|
||||||
|
documents: { toggle: true },
|
||||||
|
forums: { toggle: true },
|
||||||
|
goals: { toggle: true },
|
||||||
|
home: { toggle: true },
|
||||||
|
messages: { toggle: true },
|
||||||
|
myed: { toggle: true },
|
||||||
|
news: { toggle: true },
|
||||||
|
notices: { toggle: true },
|
||||||
|
portals: { toggle: true },
|
||||||
|
reports: { toggle: true },
|
||||||
|
settings: { toggle: true },
|
||||||
|
timetable: { toggle: true },
|
||||||
|
welcome: { toggle: true },
|
||||||
|
},
|
||||||
menuorder: [],
|
menuorder: [],
|
||||||
subjectfilters: {},
|
subjectfilters: {},
|
||||||
selectedTheme: '',
|
selectedTheme: '',
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import presetBackgrounds from "../assets/presetBackgrounds";
|
|||||||
import "./BackgroundSelector.css";
|
import "./BackgroundSelector.css";
|
||||||
import browser from "webextension-polyfill";
|
import browser from "webextension-polyfill";
|
||||||
|
|
||||||
// Custom Types and Interfaces
|
|
||||||
export interface Background {
|
export interface Background {
|
||||||
id: string;
|
id: string;
|
||||||
type: string;
|
type: string;
|
||||||
@@ -71,9 +70,9 @@ function BackgroundSelector({ isEditMode, disableTheme }: BackgroundSelectorProp
|
|||||||
try {
|
try {
|
||||||
await openDB();
|
await openDB();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// @ts-expect-error - Brave is not in the navigator type (unless you are actually using brave browser, then it is there)
|
// @ts-expect-error - Brave is not in the navigator type (unless you are actually using brave browser)
|
||||||
if (navigator.brave && await navigator.brave.isBrave() || false) {
|
if (navigator.brave && await navigator.brave.isBrave() || false) {
|
||||||
console.log('[BetterSEQTA+] Brave browser is blocking access to IndexedDB. Please disable the "Cross-site cookies blocked" setting in the Shields panel. (or you can just disable brave shields for SEQTA)');
|
console.error('[BetterSEQTA+] Brave browser is blocking access to IndexedDB. Please disable the "Cross-site cookies blocked" setting in the Shields panel. (or you can just disable brave shields for SEQTA)');
|
||||||
setBackgroundsBlocked(true);
|
setBackgroundsBlocked(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ function ThemeCreator() {
|
|||||||
description: '',
|
description: '',
|
||||||
defaultColour: '',
|
defaultColour: '',
|
||||||
CanChangeColour: true,
|
CanChangeColour: true,
|
||||||
|
allowBackgrounds: true,
|
||||||
CustomCSS: '',
|
CustomCSS: '',
|
||||||
CustomImages: [],
|
CustomImages: [],
|
||||||
});
|
});
|
||||||
@@ -167,9 +168,15 @@ function ThemeCreator() {
|
|||||||
<div className='pr-2 text-sm font-semibold'>Custom Theme Colour</div>
|
<div className='pr-2 text-sm font-semibold'>Custom Theme Colour</div>
|
||||||
<div className='pr-2 text-[11px]'>Allow users to change the theme colour</div>
|
<div className='pr-2 text-[11px]'>Allow users to change the theme colour</div>
|
||||||
</div>
|
</div>
|
||||||
<Switch
|
<Switch state={theme.CanChangeColour} onChange={value => setTheme({ ...theme, CanChangeColour: value })} />
|
||||||
state={theme.CanChangeColour}
|
</div>
|
||||||
onChange={value => setTheme({ ...theme, CanChangeColour: value })} />
|
|
||||||
|
<div className='flex items-center justify-between pt-4'>
|
||||||
|
<div>
|
||||||
|
<div className='pr-2 text-sm font-semibold'>Custom Backgrounds</div>
|
||||||
|
<div className='pr-2 text-[11px]'>Allow users to set image and video backgrounds</div>
|
||||||
|
</div>
|
||||||
|
<Switch state={theme.allowBackgrounds} onChange={value => setTheme({ ...theme, allowBackgrounds: value })} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Divider />
|
<Divider />
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ export type CustomTheme = {
|
|||||||
description: string;
|
description: string;
|
||||||
defaultColour: string;
|
defaultColour: string;
|
||||||
CanChangeColour: boolean;
|
CanChangeColour: boolean;
|
||||||
|
allowBackgrounds: boolean;
|
||||||
CustomCSS: string;
|
CustomCSS: string;
|
||||||
CustomImages: CustomImage[];
|
CustomImages: CustomImage[];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
import browser from 'webextension-polyfill';
|
import browser from 'webextension-polyfill';
|
||||||
import { SettingsState } from '../../types/storage';
|
|
||||||
|
|
||||||
export async function appendBackgroundToUI() {
|
export async function appendBackgroundToUI() {
|
||||||
const settings = await browser.storage.local.get() as SettingsState;
|
|
||||||
|
|
||||||
if (settings.theme == '') return;
|
|
||||||
|
|
||||||
const parent = document.getElementById('container');
|
const parent = document.getElementById('container');
|
||||||
|
|
||||||
// embed background.html
|
// embed background.html
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
export interface SettingsState {
|
export interface SettingsState {
|
||||||
DarkMode: boolean;
|
DarkMode: boolean;
|
||||||
theme: string;
|
selectedTheme: string;
|
||||||
animatedbk: boolean;
|
animatedbk: boolean;
|
||||||
bksliderinput: string;
|
bksliderinput: string;
|
||||||
customshortcuts: CustomShortcut[];
|
customshortcuts: CustomShortcut[];
|
||||||
|
|||||||
Reference in New Issue
Block a user