var sliderIndex = 0 function setSlider() { document.querySelector('div.slider > div.slider').innerHTML = document.querySelector('div.slider > div.slider').innerHTML.split('

').join('').split('

').join() var slides = document.querySelectorAll('div.slider > div.slider > a') document.querySelector('#main > div.slider').style.width = slides.length.toString() + '00vw' var i = 0 var slideCollection = '' while (i < slides.length) { var text = slides[i].firstChild.getAttribute('alt') var location = '/' + slides[i].getAttribute('href').split('../').join('') var imageLocation = '?attachment=' + slides[i].firstChild.getAttribute('src').split('/')[slides[i].firstChild.getAttribute('src').split('/').length - 1] slideCollection = slideCollection + '

' + text + "

" i = i + 1 } document.querySelector('#main > div.slider').insertAdjacentHTML('beforeend', slideCollection) } function slide() { var slides = document.querySelectorAll('div.slider > div.slider > a').length sliderIndex = sliderIndex + 1 if (!(sliderIndex < slides)) { sliderIndex = 0 } document.querySelector('#main > div.slider').style.marginLeft = '-' + sliderIndex.toString() + '00vw' setTimeout(slide, 5000) } function removeHome() { document.querySelector('div.menu > a:nth-of-type(2)').parentElement.removeChild(document.querySelector('div.menu > a:nth-of-type(2)')) } setSlider() setTimeout(slide, 5000) removeHome()