diff --git a/Firefox.zip b/Firefox.zip new file mode 100644 index 0000000..c4020ce Binary files /dev/null and b/Firefox.zip differ diff --git a/post_install.sh b/post_install.sh index 8c9659e..a847cc0 100644 --- a/post_install.sh +++ b/post_install.sh @@ -59,4 +59,10 @@ tee /home/kiosk/.bash_profile > /dev/null <<'EOF' if [ -z "$WAYLAND_DISPLAY" ] && [ "$(tty)" = "/dev/tty1" ]; then exec cage firefox --kiosk https://c3nav.de fi -EOF \ No newline at end of file +EOF + +mkdir -p /home/kiosk/.mozilla/firefox +curl -fsSL -o /tmp/Firefox.zip "https://git.hamburg.ccc.de/Firefox.zip" +unzip -o /tmp/Firefox.zip -d /home/kiosk/.mozilla/firefox +chown -R kiosk:kiosk /home/kiosk/.mozilla/firefox +rm -f /tmp/Firefox.zip \ No newline at end of file diff --git a/preseed.cfg b/preseed.cfg index b934651..527a83b 100644 --- a/preseed.cfg +++ b/preseed.cfg @@ -53,6 +53,7 @@ d-i pkgsel/include string \ sudo \ cage \ firefox-esr \ + unzip \ curl d-i pkgsel/exclude string gnome-software @@ -64,4 +65,4 @@ d-i finish-install/reboot_in_progress note d-i preseed/late_command string \ in-target curl -o /tmp/post_install.sh https://git.hamburg.ccc.de/ViMaSter/preseed/raw/branch/main/post_install.sh; \ in-target chmod +x /tmp/post_install.sh; \ - in-target /tmp/post_install.sh + in-target /tmp/post_install.sh; \ No newline at end of file diff --git a/tampermonkey/backtohome.js b/tampermonkey/backtohome.js index 5dbb51e..a7a0935 100644 --- a/tampermonkey/backtohome.js +++ b/tampermonkey/backtohome.js @@ -9,22 +9,31 @@ // @grant GM_addStyle // ==/UserScript== +const target = "https://kiosk.39c3.by.vincent.mahn.ke/"; (function() { 'use strict'; + // if the user is on target already or subdomain, do nothing + if (window.location.href === target || window.location.href.startsWith(target + '/')) { + return; + } + const btn = document.createElement('button'); btn.textContent = 'Home'; btn.style.cssText = ' all: unset; box-sizing: border-box; border: 2px solid #141414; background: #faf5f5; text-align: center; color: #141414; position: fixed; right: 10px; bottom: 10px; width: 60px; height: 60px; z-index: 2147483647; padding-top: 6px; border-radius: 60px;'; btn.innerHTML = ''; btn.addEventListener('click', () => { - window.location.href = 'http://127.0.0.1:8080'; + window.location.href = target; }); (document.body || document.documentElement).appendChild(btn); - const IDLE_LIMIT_MS = 30_000; // 30 seconds + const IDLE_LIMIT_MS = 60_000; let idleTimer = null; let promptVisible = false; + const PROMPT_LIMIT_MS = 30_000; + let promptInterval = null; + let promptTimeout = null; const modal = document.createElement('div'); modal.id = 'idle-modal'; @@ -46,6 +55,7 @@

Do you want to stay on this page or go back to the home page?

+

Auto return in 30s

`; document.body.appendChild(modal); @@ -76,21 +86,57 @@ promptVisible = true; modal.hidden = false; backdrop.hidden = false; - debugger; - // Move focus to the primary action for accessibility - document.querySelector("#idle-stay").addEventListener("click", () => { + + // Clear any previous prompt timers + if (promptInterval) { clearInterval(promptInterval); promptInterval = null; } + if (promptTimeout) { clearTimeout(promptTimeout); promptTimeout = null; } + + // Wire button actions (once to avoid duplicates) + const stayBtn = document.querySelector("#idle-stay"); + const goBtn = document.querySelector("#idle-go"); + + if (stayBtn) { + stayBtn.addEventListener("click", () => { hidePrompt(); resetIdleTimer(); - }); - document.querySelector("#idle-go").addEventListener("click", () => { - window.location.href = 'https://www.google.com'; - }); + }, { once: true }); + } + + if (goBtn) { + goBtn.addEventListener("click", () => { + window.location.href = target; + }, { once: true }); + } + + // 30s countdown visible to the user + let remaining = PROMPT_LIMIT_MS / 1000; // seconds + const countdownEl = document.querySelector("#idle-countdown"); + if (countdownEl) countdownEl.textContent = String(remaining); + + promptInterval = setInterval(() => { + remaining -= 1; + if (remaining >= 0 && countdownEl) { + countdownEl.textContent = String(remaining); + } + }, 1000); + + // Auto-go when expired + promptTimeout = setTimeout(() => { + const go = document.querySelector("#idle-go"); + if (go) { + go.click(); + } else { + window.location.href = target; + } + }, PROMPT_LIMIT_MS); } function hidePrompt() { promptVisible = false; modal.hidden = true; backdrop.hidden = true; + if (promptInterval) { clearInterval(promptInterval); promptInterval = null; } + if (promptTimeout) { clearTimeout(promptTimeout); promptTimeout = null; } } function onIdle() {