window.addEventListener('load' , () => {
   okruszki1();
})
function okruszki1(){
    var ts=document.querySelectorAll('.grid-kafelki').length;
    console.log(ts+'liczba');
    if(ts>0){
        localStorage.setItem('liczba',ts);
    }
    
    console.log(localStorage.getItem('liczba'));
  var link='';
  var link1='';
 var tab=[];
 var ad=window.location.href.split('/');
 var ad1=ad[ad.length-1];
    document.querySelectorAll('#mobilemenuck-146-wrap li a').forEach(links => {
      if(links.hasAttribute('style') && links.style.fontWeight){
        link='<span>'+links.innerHTML+' > </span>';
      }       
    })
    document.querySelectorAll('#mobilemenuck-530-wrap li a').forEach(links => {
        if(links.hasAttribute('style') && links.style.fontWeight){
          link='<span>'+links.innerHTML+' > </span>';
        }       
      })
      document.querySelectorAll('#mobilemenuck-227-wrap li a').forEach(links => {
        if(links.hasAttribute('style') && links.style.fontWeight){
          link='<span>'+links.innerHTML+' > </span>';
        }       
      })
    document.querySelectorAll('.menu-instytut li span').forEach(links1 => {
        if(links1.hasAttribute('style') && links1.style.fontWeight){
         tab.push('<span>'+links1.innerHTML+' > </span>');
        }   
    })
      document.querySelectorAll('.menu-instytut li a').forEach(links2 => {
        if(links2.hasAttribute('style') && links2.style.fontWeight){
         tab.push('<span>'+links2.innerHTML+' > </span>');
        }   
    })
  
    document.querySelectorAll('.menu-szkola li span').forEach(links1 => {
      if(links1.hasAttribute('style') && links1.style.fontWeight){
       tab.push('<span>'+links1.innerHTML+' > </span>');
      }   
  })
    document.querySelectorAll('.menu-szkola li a').forEach(links2 => {
      if(links2.hasAttribute('style') && links2.style.fontWeight){
       tab.push('<span>'+links2.innerHTML+' > </span>');
      }   
  })



    if(tab[2] === undefined && localStorage.getItem('liczba')>0  || tab[2] === null && localStorage.getItem('liczba')>0 ){
        
       
        try{
       document.querySelectorAll('.okruszki ol li ').forEach(okr => {
        okr.innerHTML=(link+tab[0]+tab[1]+ad1.replace('aklad','akład').replace('ial','iał').replace('konczo','kończo').replaceAll('-',' ')).replace('undefined','');
        localStorage.setItem('liczba',0);
        console.log('war');
       })
       
        }catch(error){}
       
    }else if(tab[2] === undefined || tab[2] === null ) {
      console.log('war1');
      
        document.querySelectorAll('.okruszki ol li ').forEach(okr => {
okr.innerHTML=(link+tab[0]+tab[1]).replaceAll('undefined','');

        })
    }else  if(tab[1] === undefined || tab[1] === null  ){
      console.log('war2');
      
        document.querySelectorAll('.okruszki ol li ').forEach(okr => {
            okr.innerHTML=(link+tab[0]).replace('undefined','');
        })
     }else if(tab[0] === undefined || tab[0] === null ){
      console.log('war3');
      okr.innerHTML=(link+ad1.replace('aklad','akład').replace('ial','iał').replace('konczo','kończo').replaceAll('-',' ')).replace('undefined','');
     }
     else {
      console.log('war4');
        document.querySelectorAll('.okruszki ol li ').forEach(okr => {

            okr.innerHTML=(link+tab[2]).replace('undefined','');
        })
     }
     document.querySelectorAll('.okruszki ol li span').forEach(oks => {
       oks.innerHTML=oks.innerHTML.replaceAll('>','');
     })

}