From 04f0cbd417d69a45eff07a03e5a6d727eff694d4 Mon Sep 17 00:00:00 2001 From: ygowthamr Date: Sun, 10 Nov 2024 13:26:28 +0530 Subject: [PATCH] Added unique visitors count --- visi.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/visi.js b/visi.js index 37a9da49..4e414367 100644 --- a/visi.js +++ b/visi.js @@ -5,9 +5,14 @@ function getVisitorCount() { // Function to increment and save the count function incrementVisitorCount() { - let count = parseInt(getVisitorCount()) + 1; - localStorage.setItem('visitorCount', count); - return count; + if (!localStorage.getItem('visitedHomePage')) { + let count = parseInt(getVisitorCount()) + 1; + localStorage.setItem('visitorCount', count); + localStorage.setItem('visitedHomePage', 'true'); + return count; + } + + return getVisitorCount(); } // Function to display the count