fix: fix the timetable edit plugin

This commit is contained in:
2026-04-17 15:55:32 +09:30
parent ec68cec0ca
commit f6ac112329
2 changed files with 19 additions and 4 deletions
+6 -1
View File
@@ -63,7 +63,12 @@ function resetTimetableStyles(): 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
if (settingsState.timeFormat == "12") {
+13 -3
View File
@@ -271,7 +271,9 @@ const timetableEditPlugin: Plugin<{}, TimetableStorage> = {
};
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") {
const titleEl = quickbar.querySelector(".title");
const roomEl = quickbar.querySelector(".meta .room");
@@ -287,7 +289,9 @@ const timetableEditPlugin: Plugin<{}, TimetableStorage> = {
if (!timetablePage || quickbarObserver) return;
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") {
addEditButtonToQuickbar(quickbar as HTMLElement);
}
@@ -302,7 +306,13 @@ const timetableEditPlugin: Plugin<{}, TimetableStorage> = {
};
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();
setupQuickbarObserver();
syncQuickbarFromDOM();