If you want to verify you are doing things right, I have a clip of me doing this on stream (I don't run both tests in the clip because I yap too much and ran out of time). You can see the clip here.
<script>document.body.style = "background-color: purple;" setTimeout(() => {window.location.reload()}, 1000);</script>