autobahn247365 commited on
Commit
2ecf712
·
verified ·
1 Parent(s): 9e0adec

Ghost drop v1.0 — viewer (canvas only, no selectable text)

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