Files
Home-Assistant/custom_components/ingress/www/iframe.html
T
2026-06-11 11:50:50 -04:00

49 lines
1.3 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<style>
body {
margin: 0;
height: 100vh;
overflow: hidden;
}
iframe {
border: 0;
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<script>
(() => {
const urlParams = new URLSearchParams(window.location.search);
let url = urlParams.get("ingress");
if (!url) return;
let interval = +urlParams.get("refresh");
document.querySelector("body").innerHTML = '<iframe allow="fullscreen"></iframe>';
const iframe = document.querySelector("iframe");
if (/^\/api\/hassio_ingress\/[^/]+/.test(url)) {
if (!(interval >= 5)) interval = 300;
iframe.src = url;
setInterval(() => {
fetch(url, { redirect: "manual" });
}, interval * 1000);
} else if (/^\w+(?:$|\/)/.test(url)) {
url = `/api/ingress/${url}${url.indexOf("/") === -1 ? "/" : ""}`;
iframe.src = url;
if (interval >= 5) {
setInterval(() => {
iframe.src = url;
}, interval * 1000);
}
}
iframe.addEventListener("load", () => {
document.title = iframe.contentDocument.title;
});
})();
</script>
</body>
</html>