Widget:Larifk

De Wiki Gla
Revisão de 16h00min de 13 de março de 2026 por GhoulBlack (discussão | contribs)
Ir para navegação Ir para pesquisar

<script>

(function(){

let globalEventsTimer,globalEventsImage,worldBossTimer,worldBossImage,rankedTimer,rankedImage; let globalEventsInterval,worldBossInterval,rankedInterval; let globalEventsInfo={};

const bossLinks={ "Aokiji_wb_event.png":"https://wiki.gla.com.br/index.php/Aokiji_(World_Boss)", "Barbanegra_wb_event.png":"https://wiki.gla.com.br/index.php/Barba_Negra", "Shai_hulud_wb_event.png":"https://wiki.gla.com.br/index.php/Shai-Hulud", "Plesiosaur_wb_event.png":"https://wiki.gla.com.br/index.php/Plesiosaur", "Mihawk_wb_event.png":"https://wiki.gla.com.br/index.php/Mihawk_(World_Boss)", "Bananawani_wb_event.png":"https://wiki.gla.com.br/index.php/Bananawani", "Byakko_wb_event.png":"https://wiki.gla.com.br/index.php/Byakko", "Hiking_bear_wb_event.png":"https://wiki.gla.com.br/index.php/Hiking_Bear" };

function bossLink(img,image){ const src=img||image; const file=src.split('/').pop(); const link=bossLinks[file]||'https://wiki.gla.com.br/index.php/World_Boss'; document.getElementById('worldboss-link').setAttribute('href',link); }

function pad(v){return v<10?'0'+v:v}

function getBrazilTime(){

const f=new Intl.DateTimeFormat('en-US',{ timeZone:'America/Sao_Paulo', hour12:false, year:'numeric', month:'2-digit', day:'2-digit', hour:'2-digit', minute:'2-digit', second:'2-digit' })

const parts=f.formatToParts(new Date()); const val=Object.fromEntries(parts.map(p=>[p.type,p.value]));

return new Date( parseInt(val.year), parseInt(val.month)-1, parseInt(val.day), parseInt(val.hour), parseInt(val.minute), parseInt(val.second) )

}

function worldBossCountdown(start,end){

if(worldBossInterval)clearInterval(worldBossInterval);

worldBossInterval=setInterval(()=>{

const now=getBrazilTime().getTime();

if(now<start){

const diff=start-now; const s=Math.floor(diff/1000);

const h=Math.floor(s/3600); const m=Math.floor((s%3600)/60); const sec=s%60;

worldBossTimer.innerHTML='Começa em: '+pad(h)+':'+pad(m)+':'+pad(sec)

}

else if(now>=start&&now<end){

const diff=end-now; const s=Math.floor(diff/1000);

const h=Math.floor(s/3600); const m=Math.floor((s%3600)/60); const sec=s%60;

worldBossTimer.innerHTML='Em andamento: '+pad(h)+':'+pad(m)+':'+pad(sec)

}

else{

clearInterval(worldBossInterval); worldBossTimer.innerHTML='Evento finalizado'

}

},1000)

}

async function obtenerImagenWorldBoss(modo='actual'){

try{

const r=await fetch('https://wiki.gla.com.br/index.php?title=Wbevents.json&action=raw') const data=await r.json()

const events=data.world_boss_events

const now=getBrazilTime().getTime()

for(const d of Object.keys(events).sort()){

const [y,m,day]=d.split('-').map(Number)

const start=new Date(y,m-1,day,11,0).getTime() const end=start+22*60*60*1000

if(modo==='actual'&&now>=start&&now<end)return events[d] if(modo==='proximo'&&now<start)return events[d]

}

}catch(e){}

return null

}

function setWorldBossEvent(){

const now=getBrazilTime()

const today=now.getDay()

c