mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-13 23:24:40 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d53dc9ff06 |
+1
-1
@@ -47,7 +47,7 @@
|
|||||||
"mime-types": "^3.0.1",
|
"mime-types": "^3.0.1",
|
||||||
"prettier": "^3.5.3",
|
"prettier": "^3.5.3",
|
||||||
"process": "^0.11.10",
|
"process": "^0.11.10",
|
||||||
"publish-browser-extension": "^4.0.0",
|
"publish-browser-extension": "^3.0.1",
|
||||||
"sass": "^1.85.1",
|
"sass": "^1.85.1",
|
||||||
"sass-loader": "^16.0.5",
|
"sass-loader": "^16.0.5",
|
||||||
"semver": "^7.7.1",
|
"semver": "^7.7.1",
|
||||||
|
|||||||
+4
-6
@@ -50,12 +50,10 @@ async function init() {
|
|||||||
documentLoadStyle.textContent = documentLoadCSS;
|
documentLoadStyle.textContent = documentLoadCSS;
|
||||||
document.head.appendChild(documentLoadStyle);
|
document.head.appendChild(documentLoadStyle);
|
||||||
|
|
||||||
const icons =
|
const icon = document.querySelector(
|
||||||
document.querySelectorAll<HTMLLinkElement>('link[rel*="icon"]');
|
'link[rel*="icon"]',
|
||||||
|
)! as HTMLLinkElement;
|
||||||
icons.forEach((link) => {
|
icon.href = icon48; // Change the icon
|
||||||
link.href = icon48;
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await initializeSettingsState();
|
await initializeSettingsState();
|
||||||
|
|||||||
@@ -824,7 +824,7 @@ div > ol:has(.uiFileHandlerWrapper) {
|
|||||||
[aria-labelledby="lixycoxs-tab-1"] [minlength="0"] {
|
[aria-labelledby="lixycoxs-tab-1"] [minlength="0"] {
|
||||||
min-height: 128px !important;
|
min-height: 128px !important;
|
||||||
}
|
}
|
||||||
body.student #menu > ul::before {
|
.student #menu > ul::before {
|
||||||
background-image: var(--betterseqta-logo) !important;
|
background-image: var(--betterseqta-logo) !important;
|
||||||
position: -webkit-sticky;
|
position: -webkit-sticky;
|
||||||
position: sticky;
|
position: sticky;
|
||||||
|
|||||||
@@ -147,21 +147,14 @@ export class ThemeManager {
|
|||||||
public async initialize(): Promise<void> {
|
public async initialize(): Promise<void> {
|
||||||
console.debug("[ThemeManager] Starting initialization");
|
console.debug("[ThemeManager] Starting initialization");
|
||||||
try {
|
try {
|
||||||
const neumorphicThemeId = "9a9786d1-b5fc-4a91-8c7a-f8bf7f7679ad";
|
// Check if theme creator was open during reload
|
||||||
const migrationCSS = "#title {\nbackground: transparent !important;\n}";
|
|
||||||
|
|
||||||
const theme = (await localforage.getItem(neumorphicThemeId)) as CustomTheme | null;
|
|
||||||
if (theme && theme.CustomCSS && !theme.CustomCSS.includes("#title {\nbackground: transparent !important;\n}")) {
|
|
||||||
theme.CustomCSS = theme.CustomCSS + "\n" + migrationCSS;
|
|
||||||
await localforage.setItem(neumorphicThemeId, theme);
|
|
||||||
}
|
|
||||||
|
|
||||||
const themeCreatorOpen = localStorage.getItem("themeCreatorOpen");
|
const themeCreatorOpen = localStorage.getItem("themeCreatorOpen");
|
||||||
if (themeCreatorOpen === "true") {
|
if (themeCreatorOpen === "true") {
|
||||||
console.debug(
|
console.debug(
|
||||||
"[ThemeManager] Theme creator was open, clearing preview state",
|
"[ThemeManager] Theme creator was open, clearing preview state",
|
||||||
);
|
);
|
||||||
this.clearPreview();
|
this.clearPreview();
|
||||||
|
// Clean up the flag
|
||||||
localStorage.removeItem("themeCreatorOpen");
|
localStorage.removeItem("themeCreatorOpen");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import { OpenWhatsNewPopup } from "@/seqta/utils/Openers/OpenWhatsNewPopup";
|
|||||||
import { showPrivacyNotification } from "@/seqta/utils/Openers/OpenPrivacyNotification";
|
import { showPrivacyNotification } from "@/seqta/utils/Openers/OpenPrivacyNotification";
|
||||||
|
|
||||||
import { updateTimetableTimes } from "@/seqta/utils/updateTimetableTimes";
|
import { updateTimetableTimes } from "@/seqta/utils/updateTimetableTimes";
|
||||||
import { fixTimetableColours } from "@/seqta/utils/fixTimetableColours";
|
|
||||||
|
|
||||||
// JSON content
|
// JSON content
|
||||||
import MenuitemSVGKey from "@/seqta/content/MenuItemSVGKey.json";
|
import MenuitemSVGKey from "@/seqta/content/MenuItemSVGKey.json";
|
||||||
@@ -100,11 +99,7 @@ export async function finishLoad() {
|
|||||||
await showPrivacyNotification();
|
await showPrivacyNotification();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (settingsState.justupdated && !document.getElementById("whatsnewbk") && !document.getElementById("privacy-notification")) {
|
||||||
settingsState.justupdated &&
|
|
||||||
!document.getElementById("whatsnewbk") &&
|
|
||||||
!document.getElementById("privacy-notification")
|
|
||||||
) {
|
|
||||||
OpenWhatsNewPopup();
|
OpenWhatsNewPopup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -262,7 +257,6 @@ async function LoadPageElements(): Promise<void> {
|
|||||||
},
|
},
|
||||||
async () => {
|
async () => {
|
||||||
await updateTimetableTimes();
|
await updateTimetableTimes();
|
||||||
await fixTimetableColours();
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,126 +0,0 @@
|
|||||||
import { waitForElm } from "./waitForElm";
|
|
||||||
|
|
||||||
let timetableObserver: MutationObserver | null = null;
|
|
||||||
let isOnTimetablePage = false;
|
|
||||||
let isInitialized = false;
|
|
||||||
let abortController: AbortController | null = null;
|
|
||||||
|
|
||||||
let lastSnapshot: String = "";
|
|
||||||
|
|
||||||
function checkIfOnTimetablePage(): boolean {
|
|
||||||
return window.location.hash.includes("page=/timetable");
|
|
||||||
}
|
|
||||||
|
|
||||||
function startTimetableMonitoring(): void {
|
|
||||||
if (timetableObserver) return;
|
|
||||||
|
|
||||||
const timetablePage = document.querySelector(".timetablepage");
|
|
||||||
if (!timetablePage) return;
|
|
||||||
|
|
||||||
lastSnapshot = Array.from(
|
|
||||||
timetablePage.querySelectorAll("*"),
|
|
||||||
(el) => getComputedStyle(el).color,
|
|
||||||
).join("|");
|
|
||||||
|
|
||||||
// Create observer for timetable content changes
|
|
||||||
timetableObserver = new MutationObserver((mutations) => {
|
|
||||||
const snapshot = Array.from(
|
|
||||||
timetablePage.querySelectorAll("*"),
|
|
||||||
(el) => getComputedStyle(el).color,
|
|
||||||
).join("|");
|
|
||||||
|
|
||||||
if (snapshot !== lastSnapshot) {
|
|
||||||
// implement colour fix code here
|
|
||||||
lastSnapshot = snapshot;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
timetableObserver.observe(timetablePage, {
|
|
||||||
childList: true,
|
|
||||||
subtree: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleUrlChange(): void {
|
|
||||||
const currentlyOnTimetable = checkIfOnTimetablePage();
|
|
||||||
|
|
||||||
if (currentlyOnTimetable !== isOnTimetablePage) {
|
|
||||||
isOnTimetablePage = currentlyOnTimetable;
|
|
||||||
|
|
||||||
if (isOnTimetablePage) {
|
|
||||||
// Wait a bit for the page to load, then start monitoring
|
|
||||||
setTimeout(() => {
|
|
||||||
startTimetableMonitoring();
|
|
||||||
}, 100);
|
|
||||||
} else {
|
|
||||||
stopTimetableMonitoring();
|
|
||||||
}
|
|
||||||
} else if (isOnTimetablePage) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function startUrlMonitoring(): void {
|
|
||||||
if (isInitialized) return;
|
|
||||||
isInitialized = true;
|
|
||||||
|
|
||||||
// Create abort controller for cleanup
|
|
||||||
abortController = new AbortController();
|
|
||||||
const signal = abortController.signal;
|
|
||||||
|
|
||||||
// Listen for hash changes (more efficient than polling)
|
|
||||||
window.addEventListener("hashchange", handleUrlChange, { signal });
|
|
||||||
window.addEventListener("popstate", handleUrlChange, { signal });
|
|
||||||
|
|
||||||
// Initial check
|
|
||||||
handleUrlChange();
|
|
||||||
}
|
|
||||||
|
|
||||||
function stopTimetableMonitoring(): void {
|
|
||||||
if (timetableObserver) {
|
|
||||||
timetableObserver.disconnect();
|
|
||||||
timetableObserver = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function stopUrlMonitoring(): void {
|
|
||||||
if (!isInitialized) return;
|
|
||||||
isInitialized = false;
|
|
||||||
|
|
||||||
// Abort all event listeners at once
|
|
||||||
if (abortController) {
|
|
||||||
abortController.abort();
|
|
||||||
abortController = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
stopTimetableMonitoring();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize monitoring on page load
|
|
||||||
if (typeof window !== "undefined") {
|
|
||||||
// Start URL monitoring immediately
|
|
||||||
startUrlMonitoring();
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function fixTimetableColours(): Promise<void> {
|
|
||||||
const timetablePage = document.querySelector(".timetablepage");
|
|
||||||
if (!timetablePage) return;
|
|
||||||
|
|
||||||
// Wait for time elements to exist if page is still loading
|
|
||||||
try {
|
|
||||||
await waitForElm(".timetablepage .time", true, 10);
|
|
||||||
} catch {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start continuous monitoring when this function is called
|
|
||||||
isOnTimetablePage = checkIfOnTimetablePage();
|
|
||||||
if (isOnTimetablePage) {
|
|
||||||
startTimetableMonitoring();
|
|
||||||
startUrlMonitoring();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cleanup function for when the module is unloaded
|
|
||||||
export function cleanup(): void {
|
|
||||||
stopUrlMonitoring();
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user