mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
fix: fix the timetable edit plugin
This commit is contained in:
@@ -63,7 +63,12 @@ function resetTimetableStyles(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleTimetable(): Promise<void> {
|
async function handleTimetable(): Promise<void> {
|
||||||
await waitForElm(".time", true, 10);
|
// SEQTA uses `.times` blocks on entries, not necessarily `.time`; avoid infinite polling on a missing selector.
|
||||||
|
try {
|
||||||
|
await waitForElm(".timetablepage .times, .timetablepage .entry.class", true, 50, 200);
|
||||||
|
} catch {
|
||||||
|
/* timetable body may render after the shell */
|
||||||
|
}
|
||||||
|
|
||||||
// Convert time format if needed
|
// Convert time format if needed
|
||||||
if (settingsState.timeFormat == "12") {
|
if (settingsState.timeFormat == "12") {
|
||||||
|
|||||||
@@ -271,7 +271,9 @@ const timetableEditPlugin: Plugin<{}, TimetableStorage> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const syncQuickbarFromDOM = () => {
|
const syncQuickbarFromDOM = () => {
|
||||||
const quickbar = document.querySelector(".timetablepage .quickbar.visible");
|
const quickbar = document.querySelector(
|
||||||
|
".timetablepage .quickbar.below.visible, .timetablepage .quickbar.visible",
|
||||||
|
);
|
||||||
if (quickbar && quickbar.getAttribute("data-type") === "class") {
|
if (quickbar && quickbar.getAttribute("data-type") === "class") {
|
||||||
const titleEl = quickbar.querySelector(".title");
|
const titleEl = quickbar.querySelector(".title");
|
||||||
const roomEl = quickbar.querySelector(".meta .room");
|
const roomEl = quickbar.querySelector(".meta .room");
|
||||||
@@ -287,7 +289,9 @@ const timetableEditPlugin: Plugin<{}, TimetableStorage> = {
|
|||||||
if (!timetablePage || quickbarObserver) return;
|
if (!timetablePage || quickbarObserver) return;
|
||||||
|
|
||||||
quickbarObserver = new MutationObserver(() => {
|
quickbarObserver = new MutationObserver(() => {
|
||||||
const quickbar = document.querySelector(".timetablepage .quickbar.visible");
|
const quickbar = document.querySelector(
|
||||||
|
".timetablepage .quickbar.below.visible, .timetablepage .quickbar.visible",
|
||||||
|
);
|
||||||
if (quickbar?.getAttribute("data-type") === "class") {
|
if (quickbar?.getAttribute("data-type") === "class") {
|
||||||
addEditButtonToQuickbar(quickbar as HTMLElement);
|
addEditButtonToQuickbar(quickbar as HTMLElement);
|
||||||
}
|
}
|
||||||
@@ -302,7 +306,13 @@ const timetableEditPlugin: Plugin<{}, TimetableStorage> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleTimetable = async () => {
|
const handleTimetable = async () => {
|
||||||
await waitForElm(".timetablepage .entry", true, 10, 100);
|
// Class entries (`div.entry.class`) load after the page shell; don't fail the whole
|
||||||
|
// setup if they are slow or briefly absent (e.g. navigation). Observers still catch them.
|
||||||
|
try {
|
||||||
|
await waitForElm(".timetablepage .entry.class", true, 50, 300);
|
||||||
|
} catch {
|
||||||
|
/* entries may appear later */
|
||||||
|
}
|
||||||
processAllEntries();
|
processAllEntries();
|
||||||
setupQuickbarObserver();
|
setupQuickbarObserver();
|
||||||
syncQuickbarFromDOM();
|
syncQuickbarFromDOM();
|
||||||
|
|||||||
Reference in New Issue
Block a user