diff --git a/src/content/auto_detection/detect_schooltape.ts b/src/content/auto_detection/detect_schooltape.ts new file mode 100644 index 0000000..890d3aa --- /dev/null +++ b/src/content/auto_detection/detect_schooltape.ts @@ -0,0 +1,25 @@ +async function main() { + // create marker + const marker = document.createElement("div") + marker.setAttribute("data-ultrabox-schooltape-marker", "true") + document.body.appendChild(marker) + + // set up observer + const observer = new MutationObserver(mutations => { + for (let mutation of mutations) { + if (mutation.type === "childList") { + // check for updated nodes + if (mutation.addedNodes.length > 0) { + Array.from(mutation.addedNodes).some(node => node) + } + } + } + }) +} + +//8=========D + +const marker_elem = document.querySelector("[data-ultrabox-schooltape-marker]") +if (!marker_elem) { + main() +} diff --git a/src/content/modules/launcher/launch_homepage.ts b/src/content/modules/launcher/launch_homepage.ts index 71e9d94..ef81153 100644 --- a/src/content/modules/launcher/launch_homepage.ts +++ b/src/content/modules/launcher/launch_homepage.ts @@ -64,7 +64,7 @@ function inject_launcher(): void { launcher_content_div.appendChild(timetable_element) } - setup_launcher(launcher_content_div) + setup_launcher(launcher_content_div, true) } inject_launcher() diff --git a/src/content/modules/launcher/launch_shortcut.ts b/src/content/modules/launcher/launch_shortcut.ts index a8e9bd2..a1ca3ab 100644 --- a/src/content/modules/launcher/launch_shortcut.ts +++ b/src/content/modules/launcher/launch_shortcut.ts @@ -16,7 +16,7 @@ function inject_launcher_shortcut() { launcher_popup_background.appendChild(launcher_popup) document.body.appendChild(launcher_popup_background) - const input_elem = setup_launcher(launcher_popup) + const input_elem = setup_launcher(launcher_popup, false) function enable_launcher() { launcher_popup_background.style.display = "block" diff --git a/src/content/modules/launcher/setup_launcher.ts b/src/content/modules/launcher/setup_launcher.ts index 1def642..2f1ac07 100644 --- a/src/content/modules/launcher/setup_launcher.ts +++ b/src/content/modules/launcher/setup_launcher.ts @@ -1,6 +1,6 @@ import { on_input, on_keydown } from "./main" -export default function setup_launcher(parent: HTMLDivElement): HTMLInputElement { +export default function setup_launcher(parent: HTMLDivElement, focus=false): HTMLInputElement { const launcher_input_container = document.createElement("div") launcher_input_container.id = "schoolbox-launcher" @@ -25,7 +25,9 @@ export default function setup_launcher(parent: HTMLDivElement): HTMLInputElement // select the input field launcher_input_box.addEventListener("input", on_input) launcher_input_box.addEventListener("keydown", on_keydown) - launcher_input_box.focus() + if (focus) { + launcher_input_box.focus() + } return launcher_input_box }