Skip to content

Instantly share code, notes, and snippets.

@dmamills
Created February 21, 2022 00:17
Show Gist options
  • Save dmamills/c3b29136773d58bd9d1e1ffc59e95d6d to your computer and use it in GitHub Desktop.
Save dmamills/c3b29136773d58bd9d1e1ffc59e95d6d to your computer and use it in GitHub Desktop.
this is how i write code 247
let i;
let h={};
const si=setInterval;
const ci=clearInterval;
const ls=localStorage;
const mr=Math.random;
const mf=Math.floor;
const ael='addEventListener';
const it='innerText';
const mi='mouseover';
const mo='mouseout';
const fe='forEach';
const d=document;
const cc= () => { if(i) ci(i) }
const chi= w => () => { cc(); i = si(wi(w), 100); }
const cho= () => cc
const wi= (w) => () => cw(w,mf(mr() * window.innerWidth),mf(mr() * window.innerHeight));
const cw= (w, x, y,i=false) => {
const el = d.createElement('em');
el.innerText = w;
el.style = `position: absolute; top: ${y}px; left: ${x}px;margin:0;`
el[ael](mi, chi(el[it]));
el[ael](mo, cho(el[it]));
if(!i)sh(w,x,y);
d.body.appendChild(el);
}
Array.from(d.querySelectorAll('em'))[fe](el => {
el[ael](mi, chi(el[it]));
el[ael](mo, cho(el[it]));
});
const sh = (k,x,y)=> {
if(!h[k])h[k]=[];
h[k].push(`${x},${y}`)
}
const lssh = () => ls.setItem('x', JSON.stringify(h))
const hts = () => {
h = JSON.parse(ls.getItem('x')) || {};
Object.keys(h)[fe](k => {
h[k][fe](xy => {
let p = xy.split(',');
cw(k, p[0],p[1], true);
});
});
}
setInterval(lssh, 1000*3);
hts();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment