const downloadLinks = document.querySelectorAll('.download-wait'); downloadLinks.forEach(link => { const linkToFile = link.getAttribute('hrefs'); const linkToFileEdited = linkToFile .replace('https://', 'https/') .replace(new RegExp('%', 'g'), '/'); link.setAttribute('href', `${window.location.origin}/downloadfiles/?${linkToFileEdited}`); });