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) {
|
||||
// Handle undefined onoff setting
|
||||
if (typeof storedSetting.onoff === 'undefined') {
|
||||
browser.runtime.sendMessage({ type: 'setDefaultStorage' })
|
||||
}
|
||||
@@ -797,7 +796,6 @@ function main(storedSetting: SettingsState) {
|
||||
loading()
|
||||
InjectCustomIcons()
|
||||
HideMenuItems()
|
||||
CheckLoadOnPeriods()
|
||||
tryLoad()
|
||||
|
||||
window.addEventListener('load', tryLoad)
|
||||
@@ -855,22 +853,6 @@ export function AppendElementsToDisabledPage() {
|
||||
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() {
|
||||
const ExtensionSettings = document.getElementById('ExtensionPopup')!
|
||||
const ExtensionIframe = document.getElementById('ExtensionIframe') as HTMLIFrameElement
|
||||
@@ -1174,25 +1156,6 @@ function ReplaceMenuSVG(element: HTMLElement, svg: string) {
|
||||
}
|
||||
|
||||
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) {
|
||||
// Creates Home menu button and appends it as the first child of the list
|
||||
|
||||
@@ -1433,8 +1396,6 @@ async function AddBetterSEQTAElements(toggle: any) {
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function GetLightDarkModeString(darkMode: boolean) {
|
||||
if (darkMode) {
|
||||
|
||||
Reference in New Issue
Block a user