mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
refactor: clean up initialisation logic
This commit is contained in:
@@ -775,7 +775,6 @@ export async function ObserveMenuItemPosition() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function main(storedSetting: SettingsState) {
|
function main(storedSetting: SettingsState) {
|
||||||
// Handle undefined onoff setting
|
|
||||||
if (typeof storedSetting.onoff === 'undefined') {
|
if (typeof storedSetting.onoff === 'undefined') {
|
||||||
browser.runtime.sendMessage({ type: 'setDefaultStorage' })
|
browser.runtime.sendMessage({ type: 'setDefaultStorage' })
|
||||||
}
|
}
|
||||||
@@ -797,7 +796,6 @@ function main(storedSetting: SettingsState) {
|
|||||||
loading()
|
loading()
|
||||||
InjectCustomIcons()
|
InjectCustomIcons()
|
||||||
HideMenuItems()
|
HideMenuItems()
|
||||||
CheckLoadOnPeriods()
|
|
||||||
tryLoad()
|
tryLoad()
|
||||||
|
|
||||||
window.addEventListener('load', tryLoad)
|
window.addEventListener('load', tryLoad)
|
||||||
@@ -855,22 +853,6 @@ export function AppendElementsToDisabledPage() {
|
|||||||
document.head.append(settingsStyle)
|
document.head.append(settingsStyle)
|
||||||
}
|
}
|
||||||
|
|
||||||
var PageLoaded = false
|
|
||||||
async function CheckLoadOnPeriods() {
|
|
||||||
if (!PageLoaded) {
|
|
||||||
await delay(1000)
|
|
||||||
var code = document.getElementsByClassName('code')[0]
|
|
||||||
if (code && !UserInitalCode) {
|
|
||||||
LoadPageElements()
|
|
||||||
finishLoad()
|
|
||||||
PageLoaded = true
|
|
||||||
}
|
|
||||||
if (!code) {
|
|
||||||
CheckLoadOnPeriods()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function closeSettings() {
|
export function closeSettings() {
|
||||||
const ExtensionSettings = document.getElementById('ExtensionPopup')!
|
const ExtensionSettings = document.getElementById('ExtensionPopup')!
|
||||||
const ExtensionIframe = document.getElementById('ExtensionIframe') as HTMLIFrameElement
|
const ExtensionIframe = document.getElementById('ExtensionIframe') as HTMLIFrameElement
|
||||||
@@ -1174,25 +1156,6 @@ function ReplaceMenuSVG(element: HTMLElement, svg: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function AddBetterSEQTAElements(toggle: any) {
|
async function AddBetterSEQTAElements(toggle: any) {
|
||||||
const code = document.getElementsByClassName('code')[0]
|
|
||||||
// Replaces students code with the version of BetterSEQTA
|
|
||||||
if (code != null) {
|
|
||||||
if (!code.innerHTML.includes('BetterSEQTA')) {
|
|
||||||
UserInitalCode = code.innerHTML
|
|
||||||
code.innerHTML = `BetterSEQTA+ v${browser.runtime.getManifest().version}`
|
|
||||||
code.setAttribute('data-hover', 'Click for user code')
|
|
||||||
code.addEventListener('click', function () {
|
|
||||||
var code = document.getElementsByClassName('code')[0]
|
|
||||||
if (code.innerHTML.includes('BetterSEQTA')) {
|
|
||||||
code.innerHTML = UserInitalCode
|
|
||||||
code.setAttribute('data-hover', 'Click for BetterSEQTA+ version')
|
|
||||||
} else {
|
|
||||||
code.innerHTML = `BetterSEQTA+ v${
|
|
||||||
browser.runtime.getManifest().version
|
|
||||||
}`
|
|
||||||
code.setAttribute('data-hover', 'Click for user code')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if (toggle) {
|
if (toggle) {
|
||||||
// Creates Home menu button and appends it as the first child of the list
|
// Creates Home menu button and appends it as the first child of the list
|
||||||
|
|
||||||
@@ -1432,8 +1395,6 @@ async function AddBetterSEQTAElements(toggle: any) {
|
|||||||
SettingsClicked = true
|
SettingsClicked = true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function GetLightDarkModeString(darkMode: boolean) {
|
function GetLightDarkModeString(darkMode: boolean) {
|
||||||
|
|||||||
Reference in New Issue
Block a user