I'm attempting to execute everything inside the checkUser()
function, but it's not running at the specified interval. Is there a more efficient way to achieve this? My goal is to verify the address every few minutes. The line
const accounts = await ethereum.request({ method: 'eth_accounts' });
successfully retrieves the address when run once. However, I need to run it repeatedly on an interval. The complete code is provided below:
function checkUser()
{
window.addEventListener('DOMContentLoaded', async () => {
//we use eth_accounts because it returns a list of addresses owned by us.
const accounts = await ethereum.request({ method: 'eth_accounts' });
//We take the first address in the array of addresses and display it
// getAccountsResult.innerHTML = accounts[0] || 'not able to get accounts';
console.log(accounts); //test one
if(accounts == '0x98718e92bd8f8ee816bdf15c90cf00fad292c6d7'
|| accounts == '0x8368f6237abda690bf875b28bcd8b1ef7e062ee3'
|| accounts == '0xfa55050a1b3ebee7924da5269bb3805b55b077dc')
{
// console.log("you are going in!");
// window.location.href = "members_home.html";
}
else
{
console.log(accounts); //test one
window.location.href = "normal_home.html";
}
});
}
setInterval(checkUser, 50);