function getCookie(name) { let matches = document.cookie.match(new RegExp( "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" )); return matches ? decodeURIComponent(matches[1]) : undefined; } let ss = getCookie('engine'); if(ss !== undefined){ window.addEventListener("load", (event) => { replaceLinks(); }); } function replaceLinks(){ let links = document.querySelectorAll('[data-link-params]'); links.forEach(link => { const params = JSON.parse(link.dataset.linkParams); console.log(params); link.href = params.link; link.innerHTML = params.text; if ('class' in link) { link.className += " "+link.class; } link.target = "_blank"; link.rel = "noindex nofollow"; link.removeAttribute('data-link-params'); link.removeAttribute('data-promo-params'); }); }