Compare commits
2 commits
672d33f33d
...
5f5e113c00
| Author | SHA1 | Date | |
|---|---|---|---|
|
5f5e113c00 |
|||
|
487e9e19e7 |
2 changed files with 55 additions and 9 deletions
BIN
Firefox.zip
BIN
Firefox.zip
Binary file not shown.
|
|
@ -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 = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-house-icon lucide-house"><path d="M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8"/><path d="M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/></svg>';
|
||||
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 @@
|
|||
<p>Do you want to stay on this page or go back to the home page?</p>
|
||||
<button id="idle-stay">Stay</button>
|
||||
<button id="idle-go">Go to Home</button>
|
||||
<p id="idle-countdown-msg" style="margin-top:8px">Auto return in <span id="idle-countdown">30</span>s</p>
|
||||
`;
|
||||
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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue