Created
July 3, 2023 08:27
-
-
Save Tracer1337/a77f3e8698a568eb253519baae8cce6b to your computer and use it in GitHub Desktop.
Reload a website periodically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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