-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.min.js
1 lines (1 loc) · 1.29 KB
/
index.min.js
1
const timeout=1e3*(new URLSearchParams(window.location.search).get("timeout")||60);let tick=1;function getImage(){let t=viewportWidth(),e=viewportHeight();document.querySelector("meta[name=viewport]").setAttribute("content","width="+t+",height="+e+",initial-scale=1");let n=(Math.random()+1).toString(36).substring(5),i="https://picsum.photos/seed/"+n+"/"+t+"/"+e+".webp?"+tick,o=document.getElementById("img");o.src=i;let r="https://picsum.photos/seed/"+n+"/"+2*t+"/"+2*e+".webp?"+tick;o.srcset=i+" 1x, "+r+" 2x",o.width=t,o.height=e,tick+=1}function viewportWidth(){if(window.innerWidth)return window.innerWidth;let t=document,e=t&&t.documentElement,n=t&&(t.body||t.getElementsByTagName("body")[0]),i=function(t){if(!t)return 0;let e=function(t,e){let n=t.overflow;return t.overflow=e,n||""},n=t.style,i=e(n,"hidden"),o=t.clientWidth||0;return e(n,i),o};return Math.max(i(e),i(n))}function viewportHeight(){if(window.innerHeight)return window.innerHeight;let t=document,e=t&&t.documentElement,n=t&&(t.body||t.getElementsByTagName("body")[0]),i=function(t){if(!t)return 0;let e=function(t,e){let n=t.overflow;return t.overflow=e,n||""},n=t.style,i=e(n,"hidden"),o=t.clientHeight||0;return e(n,i),o};return Math.max(i(e),i(n))}document.addEventListener("DOMContentLoaded",function(){getImage(),setInterval(getImage,timeout)});