Skip to content

Instantly share code, notes, and snippets.

@Tracer1337
Created July 3, 2023 08:27
Show Gist options
  • Save Tracer1337/a77f3e8698a568eb253519baae8cce6b to your computer and use it in GitHub Desktop.
Save Tracer1337/a77f3e8698a568eb253519baae8cce6b to your computer and use it in GitHub Desktop.
Reload a website periodically
// Copy-Paste this code into the browser console
//
// Execute with:
//
// autoReload()
//
// Or with a custom config:
//
// autoReload({ reloadInterval: 20 })
function autoReload(config = {}) {
const { container, reloadInterval, scale } = {
container: document.body,
reloadInterval: 60,
scale: 2,
...config,
}
const iframe = document.createElement("iframe")
iframe.src = window.location.href
iframe.style.width = `${scale * 100}vw`
iframe.style.height = `${scale * 100}vh`
iframe.style.transform = `scale(${1 / scale}) translate(-${100 / scale}%, -${100 / scale}%)`
container.innerHTML = ""
container.appendChild(iframe)
const reload = () => iframe.src = iframe.src
setInterval(reload, reloadInterval * 1000)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment