From 5d12d4bc06fa8ba86caab530a818af4ff5b27bd2 Mon Sep 17 00:00:00 2001 From: Ashley Date: Sat, 5 Aug 2023 20:42:58 +0000 Subject: [PATCH] add a refreshtimer :3 --- html/poketube.ejs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/html/poketube.ejs b/html/poketube.ejs index e5741e8a..bfc970b6 100644 --- a/html/poketube.ejs +++ b/html/poketube.ejs @@ -1621,7 +1621,26 @@ if (/[?&]autoplay=/.test(location.search)) { } } +// Function to refresh the page +const refreshPage = () => { + location.reload(); +}; +// Check if a timer is already set in localStorage +const timer = localStorage.getItem('refreshTimer'); + +if (timer) { + // If a timer is already set, clear it before setting a new one + clearTimeout(timer); +} + +// Set a new timer to refresh the page after 1 hour +const newTimer = setTimeout(() => { + refreshPage(); +}, 60 * 60 * 1000); // 1 hour in milliseconds + +// Save the new timer in localStorage +localStorage.setItem('refreshTimer', newTimer);