1(function () { 2 const userAgent = navigator.userAgent || navigator.vendor || window.opera; 3 const isIOS = /iPad|iPhone|iPod/.test(userAgent) && !window.MSStream; 4 const isAndroid = /Android/i.test(userAgent); 5 const isSafari = isIOS && /^((?!chrome|android|crios|fxios).)*safari/i.test(userAgent); 6 const isChromeOniOS = isIOS && /CriOS/i.test(userAgent); 7 const isFirefoxOniOS = isIOS && /FxiOS/i.test(userAgent); 8 9 const isMobile = isIOS || isAndroid; 10 if (!isMobile) return; 11 12 var path = window.location.pathname.toLowerCase().replace(/^\/|\/$/g, ""); 13 // web path : deeplink path 14 var deeplinkMap = { 15 "mtuzo-offer": "mtuzo-offer", 16 "free-credit-report": "credit-report", 17 "small-amountloan": "small-amountloan", 18 "small-amount-personal-loan": "small-amount-personal-loan", 19 "personal-loan": "personal-loan", 20 "emi-calculator": "emi-calculator", 21 "credit-card": "credit-card", 22 "free-credit-card": "credit-card", 23 "rezerv-cash": "rezerv-cash", 24 "digital-gold": "il-gold", 25 "il-gold-buy": "il-gold-buy", 26 "il-gold-gift": "il-gold-gift", 27 "il-rne": "il-rne", 28 "il-apptrack": "il-apptrack", 29 "il-jackpot": "il-jackpot", 30 "credit-plus": "credit-plus" 31 }; 32 var deeplinkKey = deeplinkMap[path] || ''; 33 var iosLink = deeplinkKey ? 'indialends://' + deeplinkKey : 'indialends://home'; 34 var androidPath = deeplinkKey ? '/' + path : '/'; 35 var androidPackage = "com.indialends.android"; 36 var playStoreURL = "https://play.google.com/store/apps/details?id=" + androidPackage; 37 var appStoreURL = "https://apps.apple.com/app/id1163514601"; 38 39 // iOS Safari native banner 40 if (isSafari) { 41 const params = new URLSearchParams({ 42 utm_source: 'mweb_app_banner', 43 utm_medium: deeplinkKey.toString().length > 0 ? deeplinkKey : 'home', 44 utm_campaign: 'generic' 45 }).toString(); 46 47 // Commenting out native banner code as per request 48 var meta = document.createElement('meta'); 49 meta.name = "apple-itunes-app"; 50 meta.content = `app-id=1163514601, app-argument=${iosLink}?${params}`; 51 document.head.appendChild(meta); 52 } else { 53 if (isChromeOniOS || isFirefoxOniOS || isAndroid) { 54 drawCustomTopBanner(); 55 } 56 } 57 58 function drawCustomTopBanner() { 59 if (!window.matchMedia("(max-width: 768px)").matches) return; 60 61 const bannerHeight = 40; 62 63 const banner = $(` 64 <a href="#" id="customTopBannerLink"> 65 <div id="customTopBanner" style=" 66 position: fixed; 67 top: 0; 68 left: 0; 69 width: 100%; 70 background: #ffffff; 71 padding: 10px 15px; 72 z-index: 9999; 73 font-family: sans-serif; 74 display: flex; 75 justify-content: space-between; 76 align-items: center; 77 border-bottom:1px solid #D9E5EE;"> 78 <div style="display:flex"> 79 <span><img src="https://cdnwebapp.indialends.com/illive/images/mobile/illogo.png" alt="logo" width="32" height="32" style="border-radius:2px;"></span> 80 <div style="padding-left:8px;"> 81 <p style="font-size: 12px; line-height: 16px; color: #111928; font-weight: 600; margin-bottom: 0px;">IndiaLends Mobile App</p> 82 <p style="font-size: 12px; line-height: 16px; color: #111928; font-weight: 400; margin-bottom: 0px;">Download or open our app to continue</p> 83 </div> 84 </div> 85 <div><img src="https://cdnapp.indialends.com/illive/images/mobile/downloadapprightarrow.svg" alt="right arrow"></div> 86 </div> 87 </a> 88 `); 89 90 // Append banner to body first, then attach click event using delegation 91 $('body').prepend(banner); 92 adjustLayout(); 93 observeCategories(); 94 // $(window).on('resize', adjustLayout); 95 96 $(document).on('click', '#customTopBannerLink', function (e) { 97 e.preventDefault(); 98 99 var now = Date.now();
100 hitCTEvent('MWeb_AppBanner_Clicked'); 101 sessionStorage.setItem("appBannerClosed", "true"); 102 103 if (isIOS) { 104 let didOpen = false; 105 106 // Listen for visibility change to detect if the app opened 107 const visibilityHandler = () => { 108 if (document.hidden) didOpen = true; 109 }; 110 document.addEventListener('visibilitychange', visibilityHandler); 111 112 // Use hidden iframe for Chrome / non-Safari 113 const iframe = document.createElement('iframe'); 114 iframe.style.display = 'none'; 115 iframe.src = iosLink; 116 document.body.appendChild(iframe); 117 118 // Fallback to App Store if app did not open 119 setTimeout(() => { 120 document.body.removeChild(iframe); 121 document.removeEventListener('visibilitychange', visibilityHandler); 122 if (!didOpen) window.location.href = appStoreURL; 123 }, 1200); 124 } else { 125 // old redirection, which also opens up the app if installed and the web page in the chrome browser 126 // let didOpen = false; 127 // window.location.href = "intent://" + window.location.hostname + androidPath + "/#Intent;scheme=https;package=" + androidPackage + ";end"; 128 // const visibilityChangeHandler = function () { 129 // if (document.hidden) { 130 // didOpen = true; 131 // } 132 // }; 133 // document.addEventListener('visibilitychange', visibilityChangeHandler); 134 // setTimeout(function () { 135 // document.removeEventListener('visibilitychange', visibilityChangeHandler); 136 // if (!didOpen) window.location.href = playStoreURL; 137 // }, 1200); 138 139 // acts as the fallback to Play Store and doesnt open the web page in the chrome browser 140 const intentURL = 141 "intent://" + window.location.hostname + androidPath + 142 "/#Intent;scheme=https;package=" + androidPackage + 143 ";S.browser_fallback_url=" + encodeURIComponent(playStoreURL) + 144 ";end"; 145 window.location = intentURL; 146 } 147 }); 148 149 function adjustLayout() { 150 requestAnimationFrame(() => { 151 const $header = $('header'); 152 const $content = $('main, .content').first(); 153 const topBannerHeight = banner.find('#customTopBanner').outerHeight() || bannerHeight; 154 155 if ($header.length) { 156 $header.css({ 157 position: 'fixed', 158 top: `${topBannerHeight}px`, 159 zIndex: 9998 160 }); 161 } 162 163 if ($content.length) { 164 const currentPaddingTop = parseInt($content.css('padding-top'), 10) || 0; 165 $content.css('padding-top', currentPaddingTop + topBannerHeight); 166 } else { 167 const $body = $('body'); 168 const currentPaddingTop = parseInt($body.css('padding-top'), 10) || 0; 169 $body.css('padding-top', currentPaddingTop + topBannerHeight); 170 } 171 172 updateCategoriesTop(); 173 }); 174 } 175 176 function updateCategoriesTop() { 177 // Shift .categories.d-block and .hf-categories.d-block to 108px top if they exist 178 if ($('#customTopBanner').length) { 179 var $categories = $('.categories'); 180 if ($categories.length) { 181 $('.categories.d-block').css('top', '108px'); 182 } 183 // For .hf-categories inside header > .hf > .hf-sub.container 184 var $hfCategories = $('header.hf .hf-sub.container .hf-categories'); 185 if ($hfCategories.length) { 186 $hfCategories.css('top', '108px'); 187 } 188 } 189 } 190 191 function observeCategories() { 192 const targetNode = document.body; 193 const config = { attributes: true, subtree: true, attributeFilter: ['class'] }; 194 195 const callback = function (mutationsList) { 196 for (const mutation of mutationsList) { 197 if (mutation.type === 'attributes' && mutation.target.classList) { 198 const el = mutation.target; 199 if (el.classList.contains('categories') && el.classList.contains('d-block')) { 200 updateCategoriesTop(); 201 } 202 } 203 } 204 }; 205 206 const observer = new MutationObserver(callback); 207 observer.observe(targetNode, config); 208 } 209 } 210 211 function hitCTEvent(eventName) { 212 var parameters = getMinimalParameters(eventName); 213 window.dataLayer.push(parameters); 214 PushCleverEvent(eventName, parameters); 215 } 216 217 function getMinimalParameters(eventName) { 218 var utm_source = ''; 219 var utm_medium = ''; 220 var utm_campaign = ''; 221 var gUserId = getCookie("g_user_id"); 222 223 var Platform = "MWeb"; // default value 224 if (isIOS) { 225 Platform = "mWeb-iOS"; 226 }
226 else if (isChromeOniOS || isFirefoxOniOS || isAndroid) { 227 Platform = "mWeb-Android"; 228 } 229 230 var CurrUrl = window.location.href; 231 var landingUrl = getCookie("web_app_landing_url"); 232 if (landingUrl != null && landingUrl.length > 0) { 233 var QIndex = landingUrl.indexOf('?'); 234 var QString = landingUrl.substring(QIndex + 1); 235 var arrQString = QString.split('&'); 236 for (var i = 0; i < arrQString.length; i++) { 237 if (arrQString[i].toLocaleLowerCase().includes('utm_source')) { 238 utm_source = arrQString[i].split('=').length > 1 ? arrQString[i].split('=')[1] : ''; 239 } 240 else if (arrQString[i].toLocaleLowerCase().includes('utm_medium')) { 241 utm_medium = arrQString[i].split('=').length > 1 ? arrQString[i].split('=')[1] : ''; 242 } 243 else if (arrQString[i].toLocaleLowerCase().includes('utm_campaign')) { 244 utm_campaign = arrQString[i].split('=').length > 1 ? arrQString[i].split('=')[1] : ''; 245 } 246 } 247 } 248 if (!(utm_source != null && utm_source.length > 0)) { 249 utm_source = 'Organic'; 250 } 251 if (!(utm_medium != null && utm_medium.length > 0)) { 252 utm_medium = 'Organic'; 253 } 254 if (!(utm_campaign != null && utm_campaign.length > 0)) { 255 utm_campaign = 'Organic'; 256 } 257 258 return { 259 event: eventName, 260 Lead_Acquisition_Source: utm_source, 261 Campaign_Medium: utm_medium, 262 Campaign_Name: utm_campaign, 263 Platform: Platform, 264 GUserID: gUserId, 265 URL: CurrUrl 266 }; 267 } 268})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.