(function () { var BREAKPOINT = 768; var MAX_TRIES = 80; var RETRY_INTERVAL = 100; function qa(sel, root) { return Array.prototype.slice.call((root || document).querySelectorAll(sel)); } function normalize(text) { return (text || '').replace(/s+/g, ' ').trim().toLowerCase(); } function findSelfLinkedItem(parentLi, topA) { var parentText = normalize(topA.textContent); if (!parentText) return null; var dropdown = parentLi.querySelector(':scope > ul.dropdown-menu'); if (!dropdown) return null; var candidates = qa(':scope > li > a', dropdown); for (var i = 0; i < candidates.length; i++) { var link = candidates[i]; if (normalize(link.textContent) === parentText) { return link; } } return null; } function bindRedirect(topA, href) { topA.setAttribute('data-basetemplate-toplink-bound', 'true'); topA.addEventListener('click', function (e) { if (window.innerWidth <= BREAKPOINT) return; window.location = href; }); } function processAll() { var topLis = qa('.menubg .navbar-nav > li.dropdown'); for (var i = 0; i < topLis.length; i++) { var parentLi = topLis[i]; if (parentLi.classList.contains('baseTemplateMega-hasMega')) continue; var topA = parentLi.querySelector(':scope > a'); if (!topA || topA.hasAttribute('data-basetemplate-toplink-bound')) continue; var match = findSelfLinkedItem(parentLi, topA); if (!match) continue; var matchLi = match.closest('li'); var href = match.href; bindRedirect(topA, href); if (matchLi) matchLi.remove(); } } function runWithRetry(fn, maxTries, interval) { var tries = 0; var t = setInterval(function () { tries++; fn(); if (tries >= maxTries) clearInterval(t); }, interval); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', function () { runWithRetry(processAll, MAX_TRIES, RETRY_INTERVAL); }); } else { runWithRetry(processAll, MAX_TRIES, RETRY_INTERVAL); } })();