<div class="AutoRefreshSection">
    <button onclick="AutoRefreshChangeStatus()">AutoRefresh</button>
    <style>
        .AutoRefreshSection {
            margin-bottom: 10px;
            border: 1px solid purple;
        }

        .AutoRefreshSection>button {
            padding: 5px 20px;
            cursor: pointer;
        }
    </style>
    <script>
        (() => {
            let AutoRefreshButton = document.querySelector(".AutoRefreshSection > button")
            AutoRefreshChangeStatus = (targ) => {
                let AutoRefreshStatus = sessionStorage.getItem('AutoRefreshStatus')
                if (AutoRefreshStatus == null) {
                    sessionStorage.setItem('AutoRefreshStatus', '1');
                    AutoRefreshButton.innerText = "AutoRefresh ON"
                } else {
                    if (AutoRefreshStatus == '1') {
                        sessionStorage.setItem('AutoRefreshStatus', '0');
                        AutoRefreshButton.innerText = "AutoRefresh OFF"
                    } else {
                        sessionStorage.setItem('AutoRefreshStatus', '1');
                        AutoRefreshButton.innerText = "AutoRefresh ON"
                    }
                }
            }
            AutoRefreshWatchStatus = () => {
                let AutoRefreshStatus = sessionStorage.getItem('AutoRefreshStatus')
                console.log(AutoRefreshStatus)
                if (AutoRefreshStatus == null) {

                } else {
                    if (AutoRefreshStatus == '1') {
                        location.reload(true)
                    } else {

                    }
                }
            }
            AutoRefreshInit = () => {
                let AutoRefreshStatus = sessionStorage.getItem('AutoRefreshStatus')
                if (AutoRefreshStatus == null) {

                } else {
                    if (AutoRefreshStatus == '1') {
                        AutoRefreshButton.innerText = "AutoRefresh ON"
                    } else {
                        AutoRefreshButton.innerText = "AutoRefresh OFF"
                    }
                }
            }

            AutoRefreshInit()

            window.setInterval("AutoRefreshWatchStatus()", 4000)

        })()
    </script>
</div>