Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. {const html=el=>html=>el.innerHTML=html;const key='klanowicze_online';const storage=localStorage.getItem(key);const config=storage?JSON.parse(storage):{top:'200px',left:'10px',hide:!1}
  2. const save=()=>localStorage.setItem(key,JSON.stringify(config))
  3. const klanowicze=document.createElement('div');klanowicze.id='klan_online';Object.assign(klanowicze.style,{position:'absolute',left:config.left,top:config.top,color:'white',width:'230px',fontSize:'13px',zIndex:500})
  4. const title=document.createElement('div');Object.assign(title.style,{textAlign:'right',fontWeight:'bold',color:'LimeGreen',font:'sans-serif',fontSize:'100%'});title.innerText='Klanowicze online';const lista=document.createElement('table');Object.assign(lista.style,{fontSize:'13px',width:'100%',fontWeight:'bold',padding:'1px',textAlign:'right'});const hide=document.createElement('div');Object.assign(hide.style,{fontSize:'13px',textAlign:'right'});
  5. const set=html(lista);let interval;const update=isFirst=>{if((g.battle&&!isFirst)||g.engineStopped)
  6. return;let url=`/engine?t=clan&a=members&aid=${g.aid}&browser_token=${g.browser_token}`;if(g.ev){url+='&ev='+g.ev;g.ev+=0.01}
  7. fetch(url,{method:'POST',credentials:'same-origin'}).then(data=>data.json()).then(({members:d})=>{if(!d)
  8. return;let html='';for(let nn=1;nn<d.length;nn+=10)
  9. if('online'===d[nn+7]&&d[nn]!==hero.nick)
  10. html+=`<tr onclick="chatTo('${d[nn]}')"><td>${d[nn]} ${d[nn+1] + d[nn+2]}</td><td style="text-align:right;" tip="${d[nn+4]},${d[nn+5]}">${d[nn+3]}</td></tr>`;set(html)})}
  11. const run=()=>(update(!0),interval=setInterval(update,10000))
  12. hide.addEventListener('mousedown',()=>{const set=html(hide);config.hide=config.hide?(lista.style.display='block',set('Zwiń'),run(),!1):(lista.style.display='none',set('Rozwiń'),clearInterval(interval),!0)
  13. save()});[title,lista,hide].forEach(el=>klanowicze.appendChild(el));$(klanowicze).draggable({start:()=>g.lock.add('ko'),stop(){g.lock.remove('ko');const{right,top}=klanowicze.style;Object.assign(config,{right,top});save()}});g.loadQueue.push({fun:()=>{if(!hero.clan)
  14. return;document.body.appendChild(klanowicze);if(!config.hide)
  15. run();const msg=document.createElement('div');msg.innerText=`Klanowicze online / Reskiezis \u{1f48e}`;msg.style.color='chartreuse';document.querySelector('#contxt').appendChild(msg)}})}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement