Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/content/auto_detection/detect_schooltape.ts
Original file line number Diff line number Diff line change
@@ -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()
}
2 changes: 1 addition & 1 deletion src/content/modules/launcher/launch_homepage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/content/modules/launcher/launch_shortcut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 4 additions & 2 deletions src/content/modules/launcher/setup_launcher.ts
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -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
}
Loading