File size: 1,940 Bytes
2ecf712 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>👻</title>
<style>body{margin:0;background:#05070d;color:#e8f0ff;font:16px system-ui;display:flex;align-items:center;justify-content:center;min-height:100vh;user-select:none;-webkit-user-select:none}
canvas{max-width:96vw;border-radius:12px}#note{position:fixed;bottom:10px;width:100%;text-align:center;font-size:12px;opacity:.5}</style></head>
<body oncontextmenu="return false"><canvas id="c"></canvas><div id="note"></div>
<script>
const unb=t=>Uint8Array.from(atob(t.replace(/-/g,'+').replace(/_/g,'/')+'==='.slice((t.length+3)%4)),c=>c.charCodeAt(0));
const note=document.getElementById('note');
function paint(lines,col){
const c=document.getElementById('c'),x=c.getContext('2d'),W=Math.min(900,innerWidth*0.96),lh=30;
x.font='22px system-ui';const wrapped=[];
lines.forEach(L=>{let w='';L.split(' ').forEach(t=>{if(x.measureText(w+t).width>W-40){wrapped.push(w);w=''}w+=t+' '});wrapped.push(w)});
c.width=W;c.height=wrapped.length*lh+40;x.fillStyle='#0b1222';x.fillRect(0,0,c.width,c.height);
x.font='22px system-ui';x.fillStyle=col;wrapped.forEach((w,i)=>x.fillText(w,20,40+i*lh));
}
(async()=>{
const [id,iv,ct]=location.hash.slice(1).split('.');
if(!id){paint(['Nothing here.'],'#888');return}
history.replaceState(null,'',location.pathname);
const r=await fetch('../api/key/'+id);
if(!r.ok){paint(['👻 Ghosted.','This drop is gone.'],'#ff3b3b');return}
const {key}=await r.json();
const k=await crypto.subtle.importKey('raw',await crypto.subtle.digest('SHA-256',unb(key)),'AES-GCM',false,['decrypt']);
try{const pt=new TextDecoder().decode(await crypto.subtle.decrypt({name:'AES-GCM',iv:unb(iv)},k,unb(ct)));
paint(pt.split('\n'),'#e8f0ff');note.textContent='seen through the mirror · can vanish any time';
}catch(e){paint(['Broken mirror.'],'#ff3b3b')}
})();
</script></body></html>
|