emerg: critical fix in course and assessments @SethBurkart123

This commit is contained in:
AdenMGB committed 2026-09-03 14:22:56 +09:30
1 parent 4fbb75ac3f
commit 2c0642f418
20 files changed
+903 -76

No files matched your search

+1 -1
View File
@@ -38,7 +38,7 @@
@layer override {
.legacy-root,
.legacy-root * {
.legacy-root *:not(.iconFamily) {
font-family: var(--betterseqta-font-family, Rubik), sans-serif !important;
}
+44 -11
View File
@@ -45,12 +45,12 @@ button.bsplus-timetable-control.iconFamily,
body,
.legacy-root input,
.legacy-root textarea,
.legacy-root button,
.legacy-root button:not(.iconFamily),
.legacy-root select,
.legacy-root option,
.legacy-root .input,
html {
font-family: Rubik, sans-serif !important;
font-family: var(--betterseqta-font-family, Rubik), sans-serif !important;
}
.legacy-root {
@@ -127,9 +127,17 @@ select option {
background: var(--auto-background) !important;
}
.legacy-root,
.legacy-root * {
font-family: Rubik, sans-serif !important;
--theme-fg-parts: white;
.legacy-root *:not(.iconFamily) {
font-family: var(--betterseqta-font-family, Rubik), sans-serif !important;
}
/* SEQTA uses `rgb(var(--theme-fg-parts))` — must be an rgb triplet, not `white`. */
html.dark .legacy-root {
--theme-fg-parts: 255, 255, 255;
}
html:not(.dark) .legacy-root {
--theme-fg-parts: 0, 0, 0;
}
.extension-editor {
background: var(--background-primary);
@@ -488,15 +496,15 @@ ul.magicDelete > li.deleting {
pointer-events: none;
}
#menu li.hasChildren.active > .sub {
#menu li.hasChildren:is(.active, .bsplus-active) > .sub {
pointer-events: auto;
}
#menu li.hasChildren.active > .sub:has(.hasChildren.active) {
#menu li.hasChildren:is(.active, .bsplus-active) > .sub:has(.hasChildren:is(.active, .bsplus-active)) {
pointer-events: none !important;
}
#menu li.hasChildren.active .hasChildren.active > .sub {
#menu li.hasChildren:is(.active, .bsplus-active) .hasChildren:is(.active, .bsplus-active) > .sub {
pointer-events: auto !important;
}
@@ -712,6 +720,17 @@ html.bsplus-custom-title-pending #title > :not(#bsplus-title-root),
box-sizing: border-box !important;
}
/* Open folder rows wrap the absolute `.sub` panel. Filters/overflow on the
row clip every course/assessment label (especially glass + Edge). */
> #bsplus-sidebar-root .bsplus-sidebar-item:has(> .sub) {
overflow: visible !important;
backdrop-filter: none !important;
-webkit-backdrop-filter: none !important;
contain: none !important;
background: transparent !important;
box-shadow: none !important;
}
> #bsplus-sidebar-root > li.item {
pointer-events: auto !important;
}
@@ -922,6 +941,20 @@ body.icon-only-sidebar:not(:has(#menu li.hasChildren:is(.active, .bsplus-active)
}
}
/* Icon-only + drill: keep subject/back labels visible even if `:has()` misses. */
body.icon-only-sidebar #menu.bsplus-custom-sidebar #bsplus-sidebar-root.drilling {
li > label,
li > label span,
.backLabel {
display: inline !important;
font-size: 16px !important;
}
li > label {
display: flex !important;
}
}
[class*="notifications__items___"] {
-ms-overflow-style: none !important;
scrollbar-width: none !important;
@@ -2044,11 +2077,11 @@ html.transparencyEffects
width: 25px;
height: 25px;
}
.dark .legacy-root button::after {
.dark .legacy-root button.iconFamily::after {
background: white;
}
.legacy-root button::after {
background: black !important;
.legacy-root button.iconFamily::after {
background: currentColor;
}
.legacy-root button:not([disabled]):focus {
border-color: var(--better-sub);
+10 -1
View File
@@ -75,13 +75,22 @@ $sidebar-motion: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
&.bsplus-sidebar-style-glass {
#{$item} {
/* Never put backdrop-filter on an open folder — it becomes a clip
containing-block and hides `.sub` labels on Chromium/Edge. */
#{$item}:not(:has(> .sub)) {
margin: 0 8px 8px !important;
background: rgba(255, 255, 255, 0.1) !important;
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}
#{$item}:has(> .sub) {
background: transparent !important;
backdrop-filter: none !important;
-webkit-backdrop-filter: none !important;
box-shadow: none !important;
overflow: visible !important;
}
#{$active} {
background: rgba(255, 255, 255, 0.2) !important;
box-shadow:
-2
View File
@@ -39,8 +39,6 @@ html.transparencyEffects {
[class*="LabelList__selected___"],
.buttonChecklist,
.pane,
.legacy-root button,
.legacy-root a,
[class*="MessageList__MessageList___"] {
backdrop-filter: blur(80px);
}
+2
View File
@@ -30,6 +30,7 @@ import {
} from "@/seqta/utils/Loaders/LoadEngageHomePage";
import { loadHomePage } from "@/seqta/utils/Loaders/LoadHomePage";
import { runStartupPopupQueue } from "@/seqta/utils/Openers/StartupPopupQueue";
import { OpenCoursesAssessmentsFixPopup } from "@/seqta/utils/Openers/OpenCoursesAssessmentsFixPopup";
import {
syncTimetableUrlMonitoring,
@@ -719,6 +720,7 @@ export function init() {
}
AppendElementsToDisabledPage();
OpenCoursesAssessmentsFixPopup();
};
const handleDisabled = () => {
+2 -2
View File
@@ -87,11 +87,11 @@ const SEQTA_FONT_SCOPE = `
.legacy-root,
.legacy-root input,
.legacy-root textarea,
.legacy-root button,
.legacy-root button:not(.iconFamily),
.legacy-root select,
.legacy-root option,
.legacy-root .input,
.legacy-root *,
.legacy-root *:not(.iconFamily),
#container,
#container *
`;
@@ -0,0 +1,87 @@
/**
* @jest-environment jsdom
*/
import {
applyCustomMenuActive,
scheduleRestoreCustomMenuActive,
} from "./customMenuActive";
describe("applyCustomMenuActive", () => {
beforeEach(() => {
document.body.innerHTML = `
<ul id="bsplus-sidebar-root" class="drilling">
<li class="item hasChildren" data-key="assessments">
<label><span>Assessments</span></label>
<div class="sub">
<div class="nav"><div class="back"><div class="backLabel">Assessments</div></div></div>
<ul>
<li class="item" data-key="4804:11066" aria-current="page">
<label><span>English</span></label>
</li>
</ul>
</div>
</li>
</ul>
`;
});
it("restores .active and .bsplus-active after SEQTA strips them", () => {
applyCustomMenuActive({
activeKey: "4804:11066",
drilling: true,
});
const folder = document.querySelector(
"#bsplus-sidebar-root > li.hasChildren",
);
const leaf = document.querySelector('li.item[data-key="4804:11066"]');
expect(folder?.classList.contains("active")).toBe(true);
expect(folder?.classList.contains("bsplus-active")).toBe(true);
expect(leaf?.classList.contains("active")).toBe(true);
expect(leaf?.classList.contains("bsplus-active")).toBe(true);
});
});
describe("scheduleRestoreCustomMenuActive", () => {
beforeEach(() => {
jest.useFakeTimers();
jest
.spyOn(window, "requestAnimationFrame")
.mockImplementation((cb: FrameRequestCallback) => {
cb(0);
return 0;
});
document.body.innerHTML = `
<ul id="bsplus-sidebar-root" class="drilling">
<li class="item hasChildren" data-key="assessments">
<div class="sub"><ul>
<li class="item" data-key="upcoming" aria-current="page"></li>
</ul></div>
</li>
</ul>
`;
});
afterEach(() => {
jest.restoreAllMocks();
jest.useRealTimers();
});
it("re-applies active classes after SEQTA strips them on the next frames", () => {
const folder = document.querySelector(
"#bsplus-sidebar-root > li.hasChildren",
) as HTMLElement;
scheduleRestoreCustomMenuActive({
activeKey: "upcoming",
drilling: true,
});
folder.classList.remove("active", "bsplus-active");
jest.advanceTimersByTime(50);
expect(folder.classList.contains("active")).toBe(true);
expect(folder.classList.contains("bsplus-active")).toBe(true);
});
});
+72
View File
@@ -0,0 +1,72 @@
export type CustomMenuActiveState = {
activeKey: string | null;
drilling: boolean;
};
function ensureActive(el: Element | null | undefined, withBsplus = false) {
if (!(el instanceof HTMLElement)) return;
if (!el.classList.contains("active")) el.classList.add("active");
if (withBsplus && !el.classList.contains("bsplus-active")) {
el.classList.add("bsplus-active");
}
}
/**
* SEQTA strips `.active` (and sometimes our `.bsplus-active`) after navigation.
* Theme chrome, `.sub` hit-testing, and icon-only expand all depend on those classes.
*/
export function applyCustomMenuActive(state: CustomMenuActiveState) {
const root = document.getElementById("bsplus-sidebar-root");
if (!root) return;
for (const li of root.querySelectorAll("li.hasChildren")) {
if (!(li instanceof HTMLElement)) continue;
if (!li.querySelector(":scope > .sub")) continue;
ensureActive(li, true);
}
const { activeKey, drilling } = state;
if (drilling) {
if (activeKey) {
ensureActive(
root.querySelector(`.sub li.item[data-key="${CSS.escape(activeKey)}"]`),
true,
);
}
for (const li of root.querySelectorAll(
'.sub li.item[aria-current="page"]',
)) {
ensureActive(li, true);
}
return;
}
if (activeKey) {
ensureActive(
root.querySelector(`li.item[data-key="${CSS.escape(activeKey)}"]`),
true,
);
}
for (const li of root.querySelectorAll('li.item[aria-current="page"]')) {
ensureActive(li, true);
}
}
let restoreTimer: ReturnType<typeof setTimeout> | null = null;
/**
* Restore after SEQTA's click/hash handlers have finished rewriting `#menu` classes.
* One rAF is not enough on assessments — SEQTA often strips `.active` a frame later.
*/
export function scheduleRestoreCustomMenuActive(state: CustomMenuActiveState) {
requestAnimationFrame(() => {
applyCustomMenuActive(state);
if (restoreTimer) clearTimeout(restoreTimer);
restoreTimer = setTimeout(() => {
restoreTimer = null;
applyCustomMenuActive(state);
}, 50);
});
}
@@ -6,6 +6,7 @@ import { waitForElm } from "@/seqta/utils/waitForElm";
import { waitForSeqtaMenu } from "@/seqta/utils/waitForSeqtaShell";
import Sidebar from "./Sidebar.svelte";
import { getNativeMenuList } from "./parseNativeMenu";
import { scheduleRestoreCustomMenuActive } from "./customMenuActive";
import {
clearNativeDrillActive,
sidebarState,
@@ -157,6 +158,12 @@ function onCustomSidebarCaptureClick(event: MouseEvent) {
function onHashChange() {
sidebarState.syncActiveFromLocation();
if (menuEl) clearNativeDrillActive(menuEl);
if (sidebarState.isDrilling) {
scheduleRestoreCustomMenuActive({
activeKey: sidebarState.activeKey,
drilling: true,
});
}
if (!sidebarState.isDrilling) return;
@@ -3,6 +3,7 @@
*/
import {
findNativeMenuEntry,
folderNeedsNativePopulate,
getPagePathFromHash,
parseNativeMenu,
} from "./parseNativeMenu";
@@ -113,4 +114,111 @@ describe("parseNativeMenu", () => {
expect(course?.dataset.path).toBe("/courses/4804:11066");
expect(assessments?.dataset.path).toBe("/assessments/4804:11066");
});
it("synthesizes assessment subject paths when SEQTA omits data-path", () => {
document.body.innerHTML = `
<div id="menu">
<ul>
<li class="item hasChildren" data-key="assessments" data-path="/assessments">
<label>Assessments</label>
<div class="sub"><ul>
<li class="item hasChildren">
<label>Year 12</label>
<div class="sub"><ul>
<li class="item" data-key="4804:11066" data-colour="#f00">
<label>English</label>
</li>
</ul></div>
</li>
</ul></div>
</li>
<li class="item hasChildren" data-key="courses" data-path="/courses">
<label>Courses</label>
<div class="sub"><ul>
<li class="item hasChildren" data-key="4804:11066">
<label>English</label>
<div class="sub"><ul>
<li class="item" data-key="4804:11066" data-path="/courses/4804:11066">
<label>Course</label>
</li>
</ul></div>
</li>
</ul></div>
</li>
</ul>
</div>
`;
const menu = document.getElementById("menu")!;
const items = parseNativeMenu(menu);
const english = items
.find((item) => item.key === "assessments")
?.children[0]?.children[0];
expect(english?.path).toBe("/assessments/4804:11066");
const native = findNativeMenuEntry(menu, {
key: "4804:11066",
id: null,
path: english?.path ?? null,
label: "English",
});
expect(native?.closest("[data-key='assessments']")).not.toBeNull();
expect(native?.closest("[data-key='courses']")).toBeNull();
});
it("detects assessments/courses folders that still need SEQTA to populate subjects", () => {
expect(
folderNeedsNativePopulate({
key: "assessments",
path: "/assessments",
id: null,
label: "Assessments",
iconHtml: "",
hasChildren: true,
itemColour: null,
betterseqta: false,
children: [
{
key: "assessments-overview",
path: null,
id: null,
label: "Overview",
iconHtml: "",
hasChildren: false,
itemColour: null,
betterseqta: true,
children: [],
},
],
}),
).toBe(true);
expect(
folderNeedsNativePopulate({
key: "courses",
path: "/courses",
id: null,
label: "Courses",
iconHtml: "",
hasChildren: true,
itemColour: null,
betterseqta: false,
children: [
{
key: "4804:11066",
path: "/courses/4804:11066",
id: null,
label: "English",
iconHtml: "",
hasChildren: true,
itemColour: null,
betterseqta: false,
children: [],
},
],
}),
).toBe(false);
});
});
+57 -7
View File
@@ -34,7 +34,22 @@ function readIconHtml(label: HTMLElement | null): string {
return svg instanceof SVGElement ? svg.outerHTML : "";
}
function parseEntry(entry: HTMLElement): SidebarItem | null {
const SUBJECT_KEY = /^\d+:\d+$/;
function inferPath(
rawPath: string | null | undefined,
key: string,
parentPath: string | null,
): string | null {
if (rawPath) return rawPath;
if (parentPath && SUBJECT_KEY.test(key)) return `${parentPath}/${key}`;
return null;
}
function parseEntry(
entry: HTMLElement,
parentPath: string | null = null,
): SidebarItem | null {
if (!entry.matches("li.item, section.item, li, section")) return null;
const label = entry.querySelector(":scope > label") as HTMLElement | null;
@@ -55,19 +70,21 @@ function parseEntry(entry: HTMLElement): SidebarItem | null {
if (!key && !labelText) return null;
const path = inferPath(entry.dataset.path, key || labelText, parentPath);
const childList = entry.querySelector(
":scope > .sub > ul",
) as HTMLElement | null;
const children = childList
? [...childList.children]
.filter((node): node is HTMLElement => node instanceof HTMLElement)
.map(parseEntry)
.map((node) => parseEntry(node, path ?? parentPath))
.filter((item): item is SidebarItem => item != null)
: [];
return {
key: key || labelText,
path: entry.dataset.path ?? null,
path,
id: entry.id || null,
label: labelText,
iconHtml: readIconHtml(label),
@@ -78,6 +95,17 @@ function parseEntry(entry: HTMLElement): SidebarItem | null {
};
}
/** True when SEQTA has not filled the Assessments/Courses submenu yet. */
export function folderNeedsNativePopulate(item: SidebarItem): boolean {
if (item.key !== "assessments" && item.key !== "courses") return false;
return !item.children.some(
(child) =>
!child.betterseqta &&
child.key !== "upcoming" &&
child.key !== "assessments-overview",
);
}
/** Parse the native SEQTA `#menu` list into a plain tree for the Svelte sidebar. */
export function parseNativeMenu(menu: HTMLElement): SidebarItem[] {
const list = getNativeMenuList(menu);
@@ -116,10 +144,32 @@ export function findNativeMenuEntry(
}
if (item.key) {
const byKey = list.querySelector(
`li[data-key="${CSS.escape(item.key)}"], section[data-key="${CSS.escape(item.key)}"]`,
);
if (byKey instanceof HTMLElement) return byKey;
const matches = [
...list.querySelectorAll<HTMLElement>(
`li[data-key="${CSS.escape(item.key)}"], section[data-key="${CSS.escape(item.key)}"]`,
),
];
if (matches.length === 1) return matches[0];
if (matches.length > 1) {
if (item.path) {
const exact = matches.find((node) => node.dataset.path === item.path);
if (exact) return exact;
const rootKey = item.path.split("/").filter(Boolean)[0];
if (rootKey) {
const underRoot = matches.find((node) =>
node.closest(`[data-key="${CSS.escape(rootKey)}"]`),
);
if (underRoot) return underRoot;
}
}
const leaf = matches.find(
(node) => !node.classList.contains("hasChildren"),
);
if (leaf) return leaf;
return matches[0];
}
}
if (item.label) {
+26 -42
View File
@@ -1,7 +1,12 @@
import { settingsState } from "@/seqta/utils/listeners/SettingsState";
import { animationsEnabled } from "@/seqta/utils/performanceMode";
import {
applyCustomMenuActive,
scheduleRestoreCustomMenuActive,
} from "./customMenuActive";
import {
findNativeMenuEntry,
folderNeedsNativePopulate,
getNativeMenuList,
getPagePathFromHash,
parseNativeMenu,
@@ -40,57 +45,28 @@ function filterVisible(items: SidebarItem[]): SidebarItem[] {
return items.filter((item) => menuItems[item.key]?.toggle !== false);
}
function ensureActive(el: Element | null | undefined) {
if (el instanceof HTMLElement && !el.classList.contains("active")) {
el.classList.add("active");
}
}
function resetSidebarScroll() {
const root = document.getElementById("bsplus-sidebar-root");
if (root instanceof HTMLElement) root.scrollTop = 0;
}
function customMenuActiveState() {
return {
activeKey: sidebarState.activeKey,
drilling: sidebarState.isDrilling,
};
}
/**
* SEQTA strips `.active` from menu items after navigation. Restore the custom list
* state so the active subject/folder still matches the route and theme chrome.
*/
export function restoreCustomMenuActive() {
const root = document.getElementById("bsplus-sidebar-root");
if (!root) return;
applyCustomMenuActive(customMenuActiveState());
}
for (const li of root.querySelectorAll("li.hasChildren")) {
if (!(li instanceof HTMLElement)) continue;
if (!li.querySelector(":scope > .sub")) continue;
ensureActive(li);
}
const activeKey = sidebarState.activeKey;
const drilling = sidebarState.isDrilling;
if (drilling) {
if (activeKey) {
ensureActive(
root.querySelector(`.sub li.item[data-key="${CSS.escape(activeKey)}"]`),
);
}
for (const li of root.querySelectorAll(
'.sub li.item[aria-current="page"]',
)) {
ensureActive(li);
}
return;
}
if (activeKey) {
ensureActive(
root.querySelector(`li.item[data-key="${CSS.escape(activeKey)}"]`),
);
}
for (const li of root.querySelectorAll('li.item[aria-current="page"]')) {
ensureActive(li);
}
function scheduleRestoreAfterSeqta() {
scheduleRestoreCustomMenuActive(customMenuActiveState());
}
/** Clear native drill state so it cannot steal pointer-events from the custom list. */
@@ -284,11 +260,18 @@ class SidebarState {
// Keep native drill closed so SEQTA CSS :has(> ul > li.hasChildren.active)
// does not lock pointer-events on the custom list.
if (menu) clearNativeDrillActive(menu);
if (menu) {
if (folderNeedsNativePopulate(item)) {
const native = findNativeMenuEntry(menu, item);
native?.click();
}
clearNativeDrillActive(menu);
}
// Absolute `.sub` panels live inside the scrollport — jump to top so the
// drilled page isn't left under the logo when the list was scrolled down.
resetSidebarScroll();
scheduleRestoreAfterSeqta();
}
clearEnterFrame(key?: string) {
@@ -378,17 +361,18 @@ class SidebarState {
// SEQTA rewrites `.active` on the route change.
if (this.isDrilling) {
this.enterFrameKey = null;
requestAnimationFrame(() => restoreCustomMenuActive());
}
const native = findNativeMenuEntry(menu, item);
if (native) {
native.click();
scheduleRestoreAfterSeqta();
return;
}
if (item.path) {
location.hash = `?page=${item.path}`;
scheduleRestoreAfterSeqta();
}
}
@@ -0,0 +1,97 @@
/**
* @jest-environment jsdom
*/
import {
markCoursesAssessmentsFixPopupSeen,
reEnableBetterSeqtaFeatures,
shouldOfferCoursesAssessmentsReEnable,
shouldShowCoursesAssessmentsFixPopup,
} from "./OpenCoursesAssessmentsFixPopup";
describe("shouldShowCoursesAssessmentsFixPopup", () => {
it("shows when BetterSEQTA features are off and the popup has not been seen", () => {
expect(
shouldShowCoursesAssessmentsFixPopup({
onoff: false,
coursesAssessmentsFixPopupShown: false,
}),
).toBe(true);
});
it("does not show when BetterSEQTA features are on unless What's New just closed", () => {
expect(
shouldShowCoursesAssessmentsFixPopup({
onoff: true,
coursesAssessmentsFixPopupShown: false,
}),
).toBe(false);
});
it("shows after What's New even when BetterSEQTA features are already on", () => {
expect(
shouldShowCoursesAssessmentsFixPopup(
{
onoff: true,
coursesAssessmentsFixPopupShown: false,
},
{ afterWhatsNew: true },
),
).toBe(true);
});
it("does not show again after the user has seen it", () => {
expect(
shouldShowCoursesAssessmentsFixPopup(
{
onoff: false,
coursesAssessmentsFixPopupShown: true,
},
{ afterWhatsNew: true },
),
).toBe(false);
});
});
describe("shouldOfferCoursesAssessmentsReEnable", () => {
it("offers re-enable only when BetterSEQTA features are off", () => {
expect(shouldOfferCoursesAssessmentsReEnable({ onoff: false })).toBe(true);
expect(shouldOfferCoursesAssessmentsReEnable({ onoff: true })).toBe(false);
});
});
describe("markCoursesAssessmentsFixPopupSeen", () => {
it("persists that the popup has been seen", () => {
const state = {
onoff: false,
coursesAssessmentsFixPopupShown: false,
};
markCoursesAssessmentsFixPopupSeen(state);
expect(state.coursesAssessmentsFixPopupShown).toBe(true);
});
});
describe("reEnableBetterSeqtaFeatures", () => {
it("turns features on, marks the popup seen, persists, then reloads", async () => {
const state = {
onoff: false,
coursesAssessmentsFixPopupShown: false,
};
const persist = jest.fn().mockResolvedValue(undefined);
const reload = jest.fn();
await reEnableBetterSeqtaFeatures({ state, persist, reload });
expect(state.onoff).toBe(true);
expect(state.coursesAssessmentsFixPopupShown).toBe(true);
expect(persist).toHaveBeenCalledWith({
onoff: true,
coursesAssessmentsFixPopupShown: true,
});
expect(reload).toHaveBeenCalledTimes(1);
expect(persist.mock.invocationCallOrder[0]).toBeLessThan(
reload.mock.invocationCallOrder[0],
);
});
});
@@ -0,0 +1,342 @@
import browser from "webextension-polyfill";
import stringToHTML from "../stringToHTML";
import { settingsState } from "../listeners/SettingsState";
import { closePopup, openPopup } from "./PopupManager";
const POPUP_STYLE_ID = "bsplus-courses-fix-popup-styles";
export type CoursesAssessmentsFixPopupState = {
onoff?: boolean;
coursesAssessmentsFixPopupShown?: boolean;
};
export function shouldShowCoursesAssessmentsFixPopup(
state: CoursesAssessmentsFixPopupState = settingsState,
options?: { afterWhatsNew?: boolean },
): boolean {
if (state.coursesAssessmentsFixPopupShown) return false;
if (options?.afterWhatsNew) return true;
return state.onoff === false;
}
export function shouldOfferCoursesAssessmentsReEnable(
state: CoursesAssessmentsFixPopupState = settingsState,
): boolean {
return state.onoff === false;
}
export function markCoursesAssessmentsFixPopupSeen(
state: CoursesAssessmentsFixPopupState = settingsState,
): void {
state.coursesAssessmentsFixPopupShown = true;
}
export async function reEnableBetterSeqtaFeatures(options?: {
state?: CoursesAssessmentsFixPopupState;
persist?: (patch: Record<string, unknown>) => Promise<void>;
reload?: () => void;
}): Promise<void> {
const state = options?.state ?? settingsState;
const persist =
options?.persist ??
((patch) => browser.storage.local.set(patch));
const reload = options?.reload ?? (() => location.reload());
markCoursesAssessmentsFixPopupSeen(state);
state.onoff = true;
await persist({
onoff: true,
coursesAssessmentsFixPopupShown: true,
});
reload();
}
function injectCoursesFixPopupStyles() {
if (document.getElementById(POPUP_STYLE_ID)) return;
const style = document.createElement("style");
style.id = POPUP_STYLE_ID;
style.textContent = `
#whatsnewbk.bsplus-courses-fix-overlay {
position: fixed !important;
inset: 0 !important;
display: grid !important;
place-items: center !important;
width: 100% !important;
height: 100% !important;
margin: 0 !important;
background: rgba(0, 0, 0, 0.55) !important;
backdrop-filter: blur(6px);
-webkit-backdrop-filter: blur(6px);
z-index: 2147483000 !important;
transform: none !important;
}
#whatsnewbk.bsplus-courses-fix-overlay .whatsnewContainer {
position: relative !important;
width: min(28rem, calc(100vw - 2rem)) !important;
height: auto !important;
max-height: calc(100vh - 2rem) !important;
margin: 0 !important;
padding: 1.75rem 1.75rem 1.5rem !important;
border-radius: 1.25rem !important;
background: #ffffff !important;
color: #111827 !important;
box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28) !important;
display: flex !important;
flex-direction: column !important;
box-sizing: border-box !important;
}
#whatsnewbk.bsplus-courses-fix-overlay.bsplus-courses-fix-overlay--dark .whatsnewContainer {
background: #1f2937 !important;
color: #ffffff !important;
}
#whatsnewbk.bsplus-courses-fix-overlay .bsplus-courses-fix-header {
margin: 0 0 1rem !important;
width: 100% !important;
height: auto !important;
min-height: unset !important;
display: flex !important;
flex-direction: column !important;
gap: 0.35rem !important;
}
#whatsnewbk.bsplus-courses-fix-overlay .bsplus-courses-fix-header h1 {
margin: 0 !important;
font-size: 1.75rem !important;
font-weight: 700 !important;
line-height: 1.15 !important;
color: inherit !important;
}
#whatsnewbk.bsplus-courses-fix-overlay .bsplus-courses-fix-header p {
margin: 0 !important;
font-size: 0.95rem !important;
font-weight: 500 !important;
color: #6b7280 !important;
}
#whatsnewbk.bsplus-courses-fix-overlay.bsplus-courses-fix-overlay--dark .bsplus-courses-fix-header p {
color: #d1d5db !important;
}
#whatsnewbk.bsplus-courses-fix-overlay .bsplus-courses-fix-body {
display: flex !important;
flex-direction: column !important;
gap: 1.25rem !important;
width: 100% !important;
margin: 0 !important;
overflow: visible !important;
}
#whatsnewbk.bsplus-courses-fix-overlay .bsplus-courses-fix-body p {
margin: 0 !important;
font-size: 1.1rem !important;
line-height: 1.55 !important;
color: inherit !important;
}
#whatsnewbk.bsplus-courses-fix-overlay .bsplus-courses-fix-body strong {
font-weight: 700 !important;
}
#whatsnewbk.bsplus-courses-fix-overlay .bsplus-courses-fix-actions {
display: flex !important;
flex-direction: column !important;
gap: 0.75rem !important;
width: 100% !important;
}
#whatsnewbk.bsplus-courses-fix-overlay .bsplus-courses-fix-btn {
width: 100% !important;
min-height: 2.75rem !important;
padding: 0.75rem 1rem !important;
border: none !important;
border-radius: 0.75rem !important;
font-size: 0.95rem !important;
font-weight: 600 !important;
font-family: inherit !important;
line-height: 1.25 !important;
cursor: pointer !important;
transition: all 0.2s ease-in-out !important;
}
#whatsnewbk.bsplus-courses-fix-overlay .bsplus-courses-fix-btn:focus {
outline: none !important;
}
#whatsnewbk.bsplus-courses-fix-overlay .bsplus-courses-fix-btn:focus-visible {
box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #2563eb !important;
}
#whatsnewbk.bsplus-courses-fix-overlay.bsplus-courses-fix-overlay--dark .bsplus-courses-fix-btn:focus-visible {
box-shadow: 0 0 0 2px #1f2937, 0 0 0 4px #2563eb !important;
}
#whatsnewbk.bsplus-courses-fix-overlay .bsplus-courses-fix-btn--primary {
background: #2563eb !important;
color: #ffffff !important;
}
#whatsnewbk.bsplus-courses-fix-overlay .bsplus-courses-fix-btn--primary:hover:not(:disabled) {
background: #1d4ed8 !important;
transform: scale(1.02) !important;
}
#whatsnewbk.bsplus-courses-fix-overlay .bsplus-courses-fix-btn--later {
background: rgba(17, 24, 39, 0.08) !important;
color: #111827 !important;
}
#whatsnewbk.bsplus-courses-fix-overlay.bsplus-courses-fix-overlay--dark .bsplus-courses-fix-btn--later {
background: rgba(255, 255, 255, 0.1) !important;
color: #ffffff !important;
}
#whatsnewbk.bsplus-courses-fix-overlay .bsplus-courses-fix-btn--later:hover:not(:disabled) {
background: rgba(17, 24, 39, 0.14) !important;
transform: scale(1.02) !important;
}
#whatsnewbk.bsplus-courses-fix-overlay.bsplus-courses-fix-overlay--dark .bsplus-courses-fix-btn--later:hover:not(:disabled) {
background: rgba(255, 255, 255, 0.16) !important;
}
#whatsnewbk.bsplus-courses-fix-overlay .bsplus-courses-fix-btn:active:not(:disabled) {
transform: scale(0.98) !important;
}
#whatsnewbk.bsplus-courses-fix-overlay .bsplus-courses-fix-btn:disabled {
opacity: 0.7 !important;
cursor: wait !important;
}
#whatsnewbk.bsplus-courses-fix-overlay .bsplus-courses-fix-btn::after {
display: none !important;
content: none !important;
}
`;
document.head.appendChild(style);
}
function setPopupButtonsDisabled(disabled: boolean) {
const reenable = document.getElementById(
"bsplus-courses-fix-reenable",
) as HTMLButtonElement | null;
const later = document.getElementById(
"bsplus-courses-fix-later",
) as HTMLButtonElement | null;
const dismiss = document.getElementById(
"bsplus-courses-fix-dismiss",
) as HTMLButtonElement | null;
if (reenable) reenable.disabled = disabled;
if (later) later.disabled = disabled;
if (dismiss) dismiss.disabled = disabled;
}
export function OpenCoursesAssessmentsFixPopup(
onDismissed?: () => void,
options?: { afterWhatsNew?: boolean },
) {
if (document.getElementById("whatsnewbk")) {
onDismissed?.();
return;
}
if (!shouldShowCoursesAssessmentsFixPopup(settingsState, options)) {
onDismissed?.();
return;
}
injectCoursesFixPopupStyles();
const offerReEnable = shouldOfferCoursesAssessmentsReEnable();
const isDark =
settingsState.DarkMode === true ||
document.documentElement.classList.contains("dark");
const header = stringToHTML(/* html */ `
<div class="whatsnewHeader bsplus-courses-fix-header">
<h1 id="bsplus-courses-fix-title">Sorry!</h1>
<p>A quick update from BetterSEQTA+</p>
</div>
`).firstChild as HTMLElement;
const bodyCopy = offerReEnable
? `We have <strong>fixed Courses and Assessments</strong>.
You can safely turn BetterSEQTA features back on.`
: `We have <strong>fixed Courses and Assessments</strong>.
They're working again now.`;
const actionsHtml = offerReEnable
? `<button type="button" id="bsplus-courses-fix-reenable" class="bsplus-courses-fix-btn bsplus-courses-fix-btn--primary">
Re-enable BetterSEQTA
</button>
<button type="button" id="bsplus-courses-fix-later" class="bsplus-courses-fix-btn bsplus-courses-fix-btn--later">
Enable later
</button>`
: `<button type="button" id="bsplus-courses-fix-dismiss" class="bsplus-courses-fix-btn bsplus-courses-fix-btn--primary">
Got it
</button>`;
const text = stringToHTML(/* html */ `
<div class="whatsnewTextContainer bsplus-courses-fix-body">
<p>
${bodyCopy}
</p>
<div class="bsplus-courses-fix-actions">
${actionsHtml}
</div>
</div>
`).firstChild as HTMLElement;
const actions = offerReEnable
? [
{
id: "bsplus-courses-fix-reenable",
onClick: async () => {
setPopupButtonsDisabled(true);
await reEnableBetterSeqtaFeatures();
},
},
{
id: "bsplus-courses-fix-later",
onClick: () => {
markCoursesAssessmentsFixPopupSeen();
void closePopup();
},
},
]
: [
{
id: "bsplus-courses-fix-dismiss",
onClick: () => {
markCoursesAssessmentsFixPopupSeen();
void closePopup();
},
},
];
openPopup({
header,
content: [text],
containerClass: "whatsnewContainer--compact",
backgroundClass: isDark
? "bsplus-courses-fix-overlay bsplus-courses-fix-overlay--dark"
: "bsplus-courses-fix-overlay",
hideCloseButton: true,
closeOnBackdrop: false,
closeOnEscape: false,
afterClose: () => {
markCoursesAssessmentsFixPopupSeen();
onDismissed?.();
},
onReady: ({ container }) => {
container.setAttribute("role", "dialog");
container.setAttribute("aria-modal", "true");
container.setAttribute("aria-labelledby", "bsplus-courses-fix-title");
},
actions,
});
}
+24 -9
View File
@@ -98,6 +98,12 @@ interface OpenPopupOptions {
actions?: PopupAction[];
/** Called after the popup DOM is mounted — use for one-off setup when actions are not enough. */
onReady?: (root: PopupRoot) => void;
/** Hide the top-right X so the user must choose an action button. */
hideCloseButton?: boolean;
/** Close when clicking the dimmed backdrop. Default true. */
closeOnBackdrop?: boolean;
/** Close when pressing Escape. Default true. */
closeOnEscape?: boolean;
}
function chainAfterClose(next?: () => void) {
@@ -138,6 +144,9 @@ export function openPopup({
backgroundClass,
actions,
onReady,
hideCloseButton = false,
closeOnBackdrop = true,
closeOnEscape = true,
}: OpenPopupOptions = {}) {
if (document.getElementById("whatsnewbk")) {
chainAfterClose(afterClose);
@@ -159,12 +168,15 @@ export function openPopup({
if (header) container.append(header);
for (const node of content) if (node) container.append(node);
const closeButton = document.createElement("div");
closeButton.id = "whatsnewclosebutton";
container.append(closeButton);
if (!hideCloseButton) {
const closeButton = document.createElement("div");
closeButton.id = "whatsnewclosebutton";
closeButton.addEventListener("click", () => void closePopup());
container.append(closeButton);
}
background.append(container);
const appContainer = document.getElementById("container");
const appContainer = document.getElementById("container") ?? document.body;
if (!appContainer) return;
appContainer.append(background);
@@ -201,12 +213,15 @@ export function openPopup({
delete settingsState.justupdated;
}
background.addEventListener("click", (event) => {
if (event.target === background) void closePopup();
});
if (closeOnBackdrop) {
background.addEventListener("click", (event) => {
if (event.target === background) void closePopup();
});
}
closeButton.addEventListener("click", () => void closePopup());
attachEscapeListener();
if (closeOnEscape) {
attachEscapeListener();
}
wirePopupActions(actions);
onReady?.({ background, container });
}
+17 -1
View File
@@ -6,12 +6,17 @@ import {
shouldShowThemeOfTheMonth,
} from "./OpenThemeOfTheMonthPopup";
import { maybeQueueFeedbackReplyPopup } from "./OpenFeedbackReplyPopup";
import {
OpenCoursesAssessmentsFixPopup,
shouldShowCoursesAssessmentsFixPopup,
} from "./OpenCoursesAssessmentsFixPopup";
import { syncApiBaseToBackground } from "../DevApiBase";
type QueueStep = (goNext: () => void) => void;
/**
* Runs startup modals in order: What's New (if the extension just updated),
* Courses/Assessments fix notice (after What's New, or if features are off),
* Theme of the Month (when the user hasn't dismissed this calendar month),
* then feedback reply notifications for pending submissions.
*/
@@ -21,11 +26,22 @@ export async function runStartupPopupQueue() {
syncApiBaseToBackground();
const steps: QueueStep[] = [];
const afterWhatsNew = !!settingsState.justupdated;
if (settingsState.justupdated) {
if (afterWhatsNew) {
steps.push((goNext) => OpenWhatsNewPopup(goNext));
}
if (
shouldShowCoursesAssessmentsFixPopup(settingsState, {
afterWhatsNew,
})
) {
steps.push((goNext) =>
OpenCoursesAssessmentsFixPopup(goNext, { afterWhatsNew }),
);
}
// Fetch the Theme of the Month before queueing so we don't show an empty
// popup if the network or server is unavailable.
const themeOfTheMonth = await fetchThemeOfTheMonth();
@@ -12,6 +12,9 @@ export const WHATS_NEW_CHANGELOG: WhatsNewRelease[] = [
"Added combined class groups in Grade Analytics to merge multiple subjects into one trend.",
"Fixed icon-only sidebar not expanding when opening a folder.",
"Fixed icon-only sidebar root labels overlapping folder view when drilling in.",
"Fixed Assessments and Courses folders going blank after SEQTA stripped sidebar active state.",
"Fixed Glass sidebar and transparency blur hiding Courses/Assessments labels on Edge.",
"Added a one-time prompt to re-enable BetterSEQTA features after the Courses and Assessments fix.",
"Fixed feedback modal not scrolling on long bug reports and replies.",
"Fixed the look and feel of the sidebar to be more like how it used to be.",
]
+1
View File
@@ -81,5 +81,6 @@ export function getDefaultSettingsState(): SettingsState {
timeFormat: "24",
privacyStatementShown: false,
bsCloudAutoSyncAnnouncementShown: false,
coursesAssessmentsFixPopupShown: false,
};
}
@@ -25,6 +25,7 @@ const OPTIONAL_UNSET_MEANS_DEFAULT_KEYS = [
"privacyStatementShown",
"privacyStatementLastUpdated",
"bsCloudAutoSyncAnnouncementShown",
"coursesAssessmentsFixPopupShown",
"themeOfTheMonthDismissedMonth",
"themeOfTheMonthLastSeenId",
"justupdated",
+2
View File
@@ -36,6 +36,8 @@ export interface SettingsState {
privacyStatementLastUpdated?: string;
/** One-time announcement: BS Cloud automatic settings sync (last in startup popup queue). */
bsCloudAutoSyncAnnouncementShown?: boolean;
/** One-time notice when BetterSEQTA features are off after the Courses/Assessments fix. */
coursesAssessmentsFixPopupShown?: boolean;
/**
* Calendar month (`YYYY-MM`) for which the user closed the Theme of the Month popup.
* Cleared automatically when a new month's entry is fetched (different `month`).