import { GetThresholdOfColor, SendNewsPage, addExtensionSettings, enableAnimatedBackground, loadHomePage, setupSettingsButton } from "../../SEQTA"; import { updateBgDurations } from "./Animation"; import { appendBackgroundToUI } from "./ImageBackgrounds"; import stringToHTML from "../utils/stringToHTML"; import { settingsState } from "../utils/listeners/SettingsState"; import { updateAllColors } from "./colors/Manager"; export async function AddBetterSEQTAElements() { console.log('AddBetterSEQTAElements'); if (settingsState.onoff) { initializeSettings(); if (settingsState.DarkMode) { document.documentElement.classList.add('dark'); } createHomeButton(); await handleUserInfo(); handleStudentData(); createNewsButton(); setupEventListeners(); } appendBackgroundToUI(); addExtensionSettings(); if (settingsState.onoff) { await createSettingsButton(); await addDarkLightToggle(); customizeMenuToggle(); } else { await createSettingsButton(); } setupSettingsButton(); } function initializeSettings() { enableAnimatedBackground(); updateBgDurations(); } function createHomeButton() { const container = document.getElementById('content')!; const div = document.createElement('div'); div.classList.add('titlebar'); container.append(div); const NewButton = stringToHTML('
'); const menu = document.getElementById('menu')!; const List = menu.firstChild! as HTMLElement; if (NewButton.firstChild) { List.insertBefore(NewButton.firstChild, List.firstChild); } } async function handleUserInfo() { try { const response = await fetch(`${location.origin}/seqta/student/login`, { method: 'POST', headers: { 'Content-Type': 'application/json; charset=utf-8', }, body: JSON.stringify({ mode: 'normal', query: null, redirect_url: location.origin, }), }); const responseData = await response.json(); let info = responseData.payload; updateUserInfo(info); } catch (error) { console.error('Error fetching and processing student data:', error); } } function updateUserInfo(info: { basic: boolean; clientIP: string[] | null; email: string | null; id: number | null; lastAccessedTime: number | null; meta: { code: string | null; governmentID: string | null; }; personUUID: string | null; status: number | null; synergeticCommunityUrl: string | null; type: string | null; userCode: string | null; userDesc: string | null; userName: string | null; }) { const titlebar = document.getElementsByClassName('titlebar')[0]; const userInfo = stringToHTML(/* html */`${info.userDesc}
${info.meta.code} // ${info.meta.governmentID}