You can use a dropdown or any suitable input field to get the refresh interval input from the user. Then store that input in Local Storage. Then, when a user refreshes the page or visits the page again, it will use the saved refresh interval.
if (localStorage.getItem("refreshTime")){
var refreshTime = localStorage.getItem("refreshTime");
}else{
var refreshTime = 60;
}
var secInterval = 0;
setInterval(function() {
console.log(secInterval);
secInterval = secInterval + 1
if (secInterval == refreshTime){
location.reload();
secInterval = 0
}
}, 1000);
function setRefreshTime(){
var refreshTimeInput = document.getElementById("refreshTime");
refreshTime = refreshTimeInput.value;
localStorage.setItem("refreshTime", refreshTime);
console.log(refreshTime);
secInterval = 0;
}
<select name="refreshTime" id="refreshTime">
<option value="5">5</option>
<option value="15">15</option>
<option value="30">30</option>
<option value="45">45</option>
<option value="60">60</option>
</select>
<input type="button" value="Set Refresh Time" onclick="setRefreshTime()"/>
CLICK HERE to find out more related problems solutions.