Untitled
(function () { try { /* main variables */ var debug = 0; var variation_name = ""; var $; /* all Pure helper functions */ function waitForElement(selector, trigger, delayInterval, delayTimeout) { var interval = setInterval(function () { if ( document && document.querySelector(selector) && document.querySelectorAll(selector).length > 0 ) { clearInterval(interval); trigger(); } }, delayInterval); setTimeout(function () { clearInterval(interval); }, delayTimeout); } let searchHtml = `<div class="eg-search_bar"></div>` /* Variation Init */ function init() { if (!document.querySelector('.eg-search_bar')) { document.body.classList.add('EG-101Search_Prominence') let headerSel = document.querySelector('#header .header-navigation'); headerSel.insertAdjacentHTML('afterend', searchHtml); } waitForElement('.header [role="search"]', function () { document.querySelector('.eg-search_bar').insertAdjacentElement('beforeend', document.querySelector('.header [role="search"]')); }, 50, 15000); waitForElement('.eg-search_bar [role="search"] .suggestions-wrapper .suggestions', function () { document.querySelector('.eg-search_bar [role="search"] .suggestions-wrapper .suggestions') .addEventListener('click', function (e) { if (e.target.closest('#search-results')) { return; } document.querySelector('.eg-search_bar .suggestions .close').click(); }); }, 50, 15000); } function removedialogbox() { const send = XMLHttpRequest.prototype.send XMLHttpRequest.prototype.send = function () { this.addEventListener('load', function () { console.log('global handler', this.responseURL) if (this.responseURL.indexOf('/SearchServices-GetSuggestions') != -1) { waitForElement('.eg-search_bar [role="search"] .suggestions-wrapper', function () { const suggestionsWrapper = document.querySelector('.eg-search_bar [role="search"] .suggestions-wrapper'); if (suggestionsWrapper && suggestionsWrapper.children.length > 0) { console.log('Suggestions-wrapper ke andar elements hain.'); document.body.classList.add('eg-overlay'); } else { console.log('Suggestions-wrapper khali hai.'); document.body.classList.remove('eg-overlay'); } }, 50, 15000); } }) return send.apply(this, arguments) } } /* Initialize variation */ if (window.innerWidth < 767) { waitForElement('#header .header-navigation', init, 50, 15000); waitForElement('#header .header-navigation', removedialogbox, 50, 15000); } } catch (e) { if (debug) console.log(e, "error in Test" + variation_name); } })();
Leave a Comment