1
|
(()=>{function l(n,s=5){return new Promise((i,t)=>{let o=URL.createObjectURL(new Blob(["(",w(),")()"],{type:"application/javascript"})),e=new Worker(o);e.onmessage=r=>{e.terminate(),i(r.data)},e.onerror=r=>{e.terminate(),t()},e.postMessage({data:n,difficulty:s}),URL.revokeObjectURL(o)})}function w(){return function(){let n=s=>{let i=new TextEncoder().encode(s);return crypto.subtle.digest("SHA-256",i.buffer).then(t=>Array.from(new Uint8Array(t)).map(o=>o.toString(16).padStart(2,"0")).join(""))};addEventListener("message",async s=>{let i=s.data.data,t=s.data.difficulty,o,e=0;do o=await n(i+e++);while(o.substring(0,t)!==Array(t+1).join("0"));e-=1,postMessage({hash:o,data:i,difficulty:t,nonce:e})})}.toString()}var h=(n="",s={})=>{let i=new URL(n,window.location.href);return Object.entries(s).forEach(t=>{let[o,e]=t;i.searchParams.set(o,e)}),i.toString()},m=n=>`/.within.website/x/cmd/anubis/static/img/${n}.webp`;(async()=>{let n=document.getElementById("status"),s=document.getElementById("image"),i=document.getElementById("title"),t=document.getElementById("spinner");n.innerHTML="Calculating...";let{challenge:o,difficulty:e}=await fetch("/.within.website/x/cmd/anubis/api/make-challenge",{method:"POST"}).then(a=>{if(!a.ok)throw new Error("Failed to fetch config");return a.json()}).catch(a=>{throw i.innerHTML="Oh no!",n.innerHTML=`Failed to fetch config: ${a.message}`,s.src=m("sad"),t.innerHTML="",t.style.display="none",a});n.innerHTML=`Calculating...<br/>Difficulty: ${e}`;let r=Date.now(),{hash:u,nonce:c}=await l(o,e),d=Date.now();i.innerHTML="Success!",n.innerHTML=`Done! Took ${d-r}ms, ${c} iterations`,s.src=m("happy"),t.innerHTML="",t.style.display="none",setTimeout(()=>{let a=window.location.href;window.location.href=h("/.within.website/x/cmd/anubis/api/pass-challenge",{response:u,nonce:c,redir:a,elapsedTime:d-r,difficulty:e})},2e3)})();})();
|