Auto Refresh Widget for Inactive Pages

Hello Elfsight team,

I would like to request a custom widget that automatically refreshes a webpage after 20 seconds of user inactivity. I have already developed the HTML/JavaScript code for this functionality and would love to integrate it using Elfsight.

The widget should:

- Monitor user activity (mouse movement, clicks, scrolling, typing).

- Automatically reload the page if no interaction is detected for 20 seconds.

Please let me know if it’s possible to publish this as a custom widget or if you can assist in embedding it through your platform.

Thank you!

<!DOCTYPE html>
<html lang="ar">
<head>
    <meta charset="UTF-8">
    <title>أداة تحديث الصفحة تلقائيًا</title>
    <script>
        let lastActivityTime = Date.now();
        const activeTabRefreshThreshold = 20000; // 20 ثانية

        function resetTimer() {
            lastActivityTime = Date.now();
        }

        ["mousemove", "keydown", "scroll", "click"].forEach(event => {
            window.addEventListener(event, resetTimer);
        });

        setInterval(() => {
            if (Date.now() - lastActivityTime > activeTabRefreshThreshold) {
                location.reload();
            }
        }, 5000); // فحص كل 5 ثواني
    </script>
</head>
<body>
    <h2 style="text-align:center; font-family:Arial">🌀 هذه الصفحة تُحدث نفسها تلقائيًا عند الخمول</h2>
    <p style="text-align:center">إذا لم يتم التفاعل مع الصفحة لمدة 20 ثانية، سيتم تحديثها تلقائيًا.</p>
</body>
</html>
2 Likes

Hey there and welcome aboard, @Tamer_Soliman :waving_hand:

Thanks for the idea!

We can’t promise that such an app will be released. However, if this request gets more votes, it might be considered in the future :slightly_smiling_face:

1 Like