-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplugin.js
1 lines (1 loc) · 1.4 KB
/
plugin.js
1
const detect=function(A=[]){var t=[{type:"webp",url:"data:image/webp;base64,UklGRhwAAABXRUJQVlA4TBAAAAAvAAAAEAfQpv5HmQMR0f8A"},{type:"avif",url:"data:image/avif;base64,AAAAHGZ0eXBtaWYxAAAAAG1pZjFhdmlmbWlhZgAAAPFtZXRhAAAAAAAAACFoZGxyAAAAAAAAAABwaWN0AAAAAAAAAAAAAAAAAAAAAA5waXRtAAAAAAABAAAAHmlsb2MAAAAABEAAAQABAAAAAAEVAAEAAAAeAAAAKGlpbmYAAAAAAAEAAAAaaW5mZQIAAAAAAQAAYXYwMUltYWdlAAAAAHBpcHJwAAAAUWlwY28AAAAUaXNwZQAAAAAAAAABAAAAAQAAABBwYXNwAAAAAQAAAAEAAAAVYXYxQ4EgAAAKBzgABpAQ0AIAAAAQcGl4aQAAAAADCAgIAAAAF2lwbWEAAAAAAAAAAQABBAECg4QAAAAmbWRhdAoHOAAGkBDQAjITFkAAAEgAAAB5TNw9UxdXU6F6oA == "}].concat(A),e={},o=[],a=document.querySelector('html');return t.map(((A,t)=>{!function(A){let t=new Image;t.src=A.url,t.onerror=function(t){var s=new Set(a.getAttribute("class")?a.getAttribute("class").split(" "):[]);o.push(new Promise((function(t,o){e[A.type.toLowerCase()]=!1,t({[A.type.toLowerCase()]:!1})}))),s.add("no-"+A.type.toLowerCase()),a.setAttribute("class",[...s].join(" ")),console.log(A.type.toUpperCase()+" not supported in this browser",t)},t.onload=function(t){var s=new Set(a.getAttribute("class")?a.getAttribute("class").split(" "):[]);o.push(new Promise((function(t,o){e[A.type.toLowerCase()]=!0,t({[A.type.toLowerCase()]:!0})}))),s.add(A.type.toLowerCase()),a.setAttribute("class",[...s].join(" ")),console.log(A.type.toUpperCase()+" supported in this browser")}}(A)})),Promise.all(o).then((function(){return e}))};detect()