feat: add Google Calendar timetable sync via accounts OAuth

OAuth flows through accounts.betterseqta.org with token exchange server-side. Sync runs in the content script to avoid MV3 service worker timeouts. Adds Svelte calendar sync UI on the timetable page, extension asset URL helper, and excludes calendar tokens from cloud sync.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-27 11:51:48 +09:30
parent bd13042fe4
commit e6b8be6821
29 changed files with 1984 additions and 17 deletions
@@ -0,0 +1,53 @@
import { mount, unmount } from "svelte";
import CalendarSyncControl from "./CalendarSyncControl.svelte";
import { syncCalendarSyncTheme } from "./calendarSyncTheme";
import hostStyles from "./calendarSyncHost.css?inline";
const CONTROLS_CLASS = "timetable-calendar-controls";
const HOST_STYLE_ID = "bsplus-calendar-sync-host-styles";
let currentApp: ReturnType<typeof mount> | null = null;
let mountRoot: HTMLElement | null = null;
function ensureHostStyles() {
if (document.getElementById(HOST_STYLE_ID)) return;
const style = document.createElement("style");
style.id = HOST_STYLE_ID;
style.textContent = hostStyles;
document.head.appendChild(style);
}
function teardown() {
if (currentApp) {
unmount(currentApp);
currentApp = null;
}
mountRoot = null;
document.querySelector(`.${CONTROLS_CLASS}`)?.remove();
document.getElementById(HOST_STYLE_ID)?.remove();
}
export async function mountGoogleCalendarButton(): Promise<void> {
if (document.querySelector(`.${CONTROLS_CLASS}`)) return;
const toolbar = document.getElementById("toolbar");
if (!toolbar) return;
ensureHostStyles();
const controls = document.createElement("div");
controls.className = `${CONTROLS_CLASS} bsplus-timetable-control`;
toolbar.appendChild(controls);
mountRoot = document.createElement("div");
mountRoot.className = "bsplus-calendar-sync-mount";
syncCalendarSyncTheme(mountRoot);
controls.appendChild(mountRoot);
currentApp = mount(CalendarSyncControl, { target: mountRoot });
}
export function unmountGoogleCalendarButton(): void {
teardown();
}