change timer to 7 seconds, shown once a day

This commit is contained in:
localhost 2026-02-20 23:00:50 +01:00
parent 6bdcfa7e8a
commit 43eb4c93d2
1 changed files with 10 additions and 10 deletions

View File

@ -21,7 +21,7 @@
<p>By continuing, you agree to use PreserveTube in that spirit.</p> <p>By continuing, you agree to use PreserveTube in that spirit.</p>
<div class="intro-footer"> <div class="intro-footer">
<button id="decline-instructions" type="button">Cancel</button> <button id="decline-instructions" type="button">Cancel</button>
<button id="accept-instructions" type="button" disabled>Continue (3s)</button> <button id="accept-instructions" type="button" disabled>Continue (7s)</button>
</div> </div>
</div> </div>
</div> </div>
@ -35,13 +35,12 @@
</h3> </h3>
</div> </div>
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script> <script src="https://js.hcaptcha.com/1/api.js" async defer></script>
<script> <script>
const url = "<%= it.url %>" const url = "<%= it.url %>"
const websocket = "<%= it.websocket %>" const websocket = "<%= it.websocket %>"
const sitekey = "<%= it.sitekey %>" const sitekey = "<%= it.sitekey %>"
let ws = null let ws = null
const hasSeenSaveInstructionsKey = "preservetube-save-instructions-seen"
const h1 = document.getElementById("title") const h1 = document.getElementById("title")
const h3 = document.getElementById("bottom") const h3 = document.getElementById("bottom")
const captcha = document.getElementById("captcha") const captcha = document.getElementById("captcha")
@ -64,7 +63,7 @@
return return
} else if (msg.data.startsWith('CAPTCHA -')) { } else if (msg.data.startsWith('CAPTCHA -')) {
captcha.style.display = 'block' captcha.style.display = 'block'
turnstile.render('#captcha', { hcaptcha.render(captcha, {
sitekey: sitekey, sitekey: sitekey,
callback: function(token) { callback: function(token) {
captcha.remove() captcha.remove()
@ -85,20 +84,21 @@
} }
function runFirstSaveGate() { function runFirstSaveGate() {
let hasSeenInstructions = false const today = new Date().toISOString().split('T')[0]
let lastDisclaimerDate = null
try { try {
hasSeenInstructions = localStorage.getItem(hasSeenSaveInstructionsKey) == "1" lastDisclaimerDate = localStorage.getItem("last-shown-disclaimer")
} catch { } catch {
hasSeenInstructions = false lastDisclaimerDate = null
} }
if (hasSeenInstructions) { if (lastDisclaimerDate === today) {
startSaveFlow() startSaveFlow()
return return
} }
backdrop.style.display = "block" backdrop.style.display = "block"
let secondsRemaining = 3 let secondsRemaining = 7
const timer = setInterval(() => { const timer = setInterval(() => {
secondsRemaining -= 1 secondsRemaining -= 1
if (secondsRemaining <= 0) { if (secondsRemaining <= 0) {
@ -113,7 +113,7 @@
acceptInstructions.addEventListener("click", () => { acceptInstructions.addEventListener("click", () => {
try { try {
localStorage.setItem(hasSeenSaveInstructionsKey, "1") localStorage.setItem("last-shown-disclaimer", today)
} catch { } catch {
} }