1/* Cookie Functions */ 2function isCookieEnabled() { 3 var cookieEnabled = (navigator.cookieEnabled) ? true : false; 4 if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled) 5 { 6 document.cookie="testcookie"; 7 cookieEnabled = (document.cookie.indexOf("testcookie") != -1) ? true : false; 8 } 9 return (cookieEnabled); 10} 11 12function clearBrokenCookies() { 13 // Parse cookies 14 const parsedCookies = document.cookie.split(';').map(e => e.trim()); 15 // Delete duplicate banner cookies 16 if (parsedCookies.filter(e => e.includes('getmailbird_com_banner_cookie')).length > 1) { 17 document.cookie = "getmailbird_com_shown_campaign_banner_cookie=;expires=Thu, 01 Jan 1970 00:00:01 GMT"; 18 document.cookie = "getmailbird_com_shown_campaign_banner_cookie=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=getmailbird.com"; 19 document.cookie = "getmailbird_com_shown_campaign_banner_cookie=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=.getmailbird.com"; 20 document.cookie = "getmailbird_com_banner_expired_cookie=;expires=Thu, 01 Jan 1970 00:00:01 GMT"; 21 document.cookie = "getmailbird_com_banner_expired_cookie=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=getmailbird.com"; 22 document.cookie = "getmailbird_com_banner_expired_cookie=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=.getmailbird.com"; 23 document.cookie = "getmailbird_com_banner_cookie=;expires=Thu, 01 Jan 1970 00:00:01 GMT"; 24 document.cookie = "getmailbird_com_banner_cookie=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=getmailbird.com"; 25 document.cookie = "getmailbird_com_banner_cookie=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=.getmailbird.com"; 26 } 27 // Delete banner duration cookie 28 document.cookie = "getmailbird_com_banner_duration_cookie=;expires=Thu, 01 Jan 1970 00:00:01 GMT"; 29 document.cookie = "getmailbird_com_banner_duration_cookie=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=getmailbird.com"; 30 document.cookie = "getmailbird_com_banner_duration_cookie=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=.getmailbird.com"; 31 // Delete promotional cookies 32 const cookies_list = [ 33 'getmailbird_com_8th_birthday_sale', 34 'getmailbird_com_black_friday_2019', 35 'getmailbird_com_black_friday_2020', 36 'getmailbird_com_black_friday_2021', 37 'getmailbird_com_black_friday_2022' 38 ]; 39 const unwantedCookies = parsedCookies.filter(c => cookies_list.some(cl => c.includes(cl))); 40 if (unwantedCookies.length) { 41 dataLayer.push({'event': 'eventTracking', 'category': 'Bug Report', 'action': '[CODE] Cleared leftover cookies' }); 42 document.cookie = "getmailbird_com_8th_birthday_sale=;expires=Thu, 01 Jan 1970 00:00:01 GMT"; 43 document.cookie = "getmailbird_com_8th_birthday_sale=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=getmailbird.com"; 44 document.cookie = "getmailbird_com_8th_birthday_sale=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=.getmailbird.com"; 45 document.cookie = "getmailbird_com_black_friday_2019=;expires=Thu, 01 Jan 1970 00:00:01 GMT"; 46 document.cookie = "getmailbird_com_black_friday_2019=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=getmailbird.com"; 47 document.cookie = "getmailbird_com_black_friday_2019=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=.getmailbird.com"; 48 document.cookie = "getmailbird_com_black_friday_2020=;expires=Thu, 01 Jan 1970 00:00:01 GMT"; 49 document.cookie = "getmailbird_com_black_friday_2020=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=getmailbird.com"; 50 document.cookie = "getmailbird_com_black_friday_2020=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=.getmailbird.com"; 51 document.cookie = "getmailbird_com_black_friday_2021=;expires=Thu, 01 Jan 1970 00:00:01 GMT"; 52 document.cookie = "getmailbird_com_black_friday_2021=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=getmailbird.com"; 53 document.cookie = "getmailbird_com_black_friday_2021=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=.getmailbird.com"; 54 document.cookie = "getmailbird_com_black_friday_2022=;expires=Thu, 01 Jan 1970 00:00:01 GMT"; 55 document.cookie = "getmailbird_com_black_friday_2022=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=getmailbird.com"; 56 document.cookie = "getmailbird_com_black_friday_2022=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=.getmailbird.com"; 57 } 58} 59 60function readCookie(name) { 61 // Clear broken cookies 62 clearBrokenCookies(); 63 64 var nameEQ = name + "="; 65 var ca = document.cookie.split(';'); 66 for(var i=0;i < ca.length;i++) { 67 var c = ca[i]; 68 while (c.charAt(0)==' ') c = c.substring(1,c.length); 69 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); 70 } 71 return null; 72} 73function createCookie(name,value,days) { 74 var expires = ""; 75 if (days) { 76 var date = new Date(); 77 date.setTime(date.getTime()+(days*24*60*60*1000)); 78 } 79 document.cookie = name+"="+value+expires+"; path=/; domain=getmailbird.com"; 80} 81 82/* Handle Navigation */ 83function handleNavigation() { 84 let isBrightHeader = !!document.querySelector("header.bright-header .navbar");
85 let currentlogoel = document.querySelector(".navbar-light #mb-logo img"); 86 if(currentlogoel) { 87 var currentlogo = '/' + currentlogoel.src.replace( /^[a-zA-Z]{3,5}\:\/{2}[a-zA-Z0-9_.:-]+\//, '' ); 88 } 89 // if(document.querySelector('.blog-template') != null) return; 90 if (window.scrollY > 1) { 91 document.querySelector("#mbmainmenu")?.classList.add('scrolledin'); 92 if(null != currentlogoel && currentlogo != functions_js_vars.mblogodark) { 93 document.querySelector("#mb-logo img").src = functions_js_vars.mblogodark; 94 } 95 } else { 96 document.querySelector("#mbmainmenu")?.classList.remove('scrolledin'); 97 if(!isBrightHeader && null != currentlogoel && currentlogo != functions_js_vars.mblogolight) { 98 document.querySelector("#mb-logo img").src = functions_js_vars.mblogolight; 99 } else if (isBrightHeader && null != currentlogoel && currentlogo != functions_js_vars.mblogodark) { 100 document.querySelector("#mb-logo img").src = functions_js_vars.mblogodark; 101 } 102 } 103} 104 105/* Downloads Counter */ 106function fetchDownloadData() { 107 108 // Download data count endpoint 109 const dtcount = 'https://argos.getmailbird.com/client/count'; 110 111 // Additional variables 112 const downloadsnumberholderid = 'downloadsNumHolder'; 113 const downloadsnumberholdersmallclass = 'downloadsNumHolderSmall'; 114 const downloadsnumbercontainerid = 'downloadsNumContainer'; 115 let downloadCountStart = 0; 116 let downloadCountCurrent = 0; 117 118 if(downloadCounterExp == true && document.domain.split('.').reverse().splice(0,2).reverse().join('.') == 'getmailbird.com' && !window.location.href.includes('/downloading/')) { 119 120 fetchDownloadsData(); 121 122 // Handle page visibility change 123 var isPageVisible = true; 124 125 // This is run on intervals (only when the download button is in viewport) 126 async function fetchDownloadsData() { 127 while (isPageVisible == false) // Suspend execution when page is not focused 128 await new Promise(r => setTimeout(r, 1000)); 129 130 fetch(dtcount, { 131 mode: 'cors', 132 method: 'GET', 133 headers: { 134 'Content-Type': 'application/json', 135 'X-Requested-With': 'XMLHttpRequest' 136 }, 137 }) 138 .then(response => response.json()) 139 .then(data => { 140 141 // Store our number of downloads variable 142 let downloadsNum = data.downloadsNumber; 143 if(downloadCountStart === 0) { 144 downloadCountStart = downloadsNum; 145 } 146 147 var downloadsNumContainer = document.querySelector('#' + downloadsnumbercontainerid); 148 149 if(document.querySelector('.fdbCurrentDownloadsNum')) { 150 document.querySelector('.fdbCurrentDownloadsNum').innerText = new Intl.NumberFormat('en-US').format(downloadsNum); 151 } 152 153 if(document.querySelector('#' + downloadsnumberholderid)) { 154 document.querySelector('#' + downloadsnumberholderid).innerText = new Intl.NumberFormat('en-US').format(downloadsNum); 155 } 156 157 document.querySelectorAll('.' + downloadsnumberholdersmallclass).forEach(function (el) { 158 el.innerText = new Intl.NumberFormat('en-US', { notation: 'compact', maximumFractionDigits: 1 }).format(downloadsNum); 159 }); 160 161 if(downloadsNumContainer) { 162 downloadsNumContainer.dataset.target = downloadsNum; 163 } 164 165 downloadCountCurrent = downloadsNum - downloadCountStart; 166 167 if(document.querySelector('.fdnDownloadsSinceNum') && downloadCountCurrent > parseInt(document.querySelector('.fdnDownloadsSinceNum').dataset.current) && document.querySelector('.fdnDownloadsSinceNum')) { 168 document.querySelector('.fdnDownloadsSinceNum').dataset.current = downloadCountCurrent; 169 document.querySelector('.fdnDownloadsSinceNum').innerText = new Intl.NumberFormat('en-US').format(downloadCountCurrent); 170 if(document.querySelector('.fdnDownloadsSinceNum').dataset.current >= 2 && readCookie(downloadCounterCookieName)) { 171 // we don't want to show this on the homepage 172 // We added a timeout to accommodate for experiment 173 setTimeout(function () { 174 if(!document.querySelector('body.nodownloadtoast')) { 175 toastdownloadnotificationShow(); 176 } 177 }, 5000); 178 } 179 } 180 181 setTimeout(fetchDownloadsData, checkInterval); 182 183 }) 184 .catch(error => { 185 console.log(error); 186 }); 187 } 188 189 // Check if tab is visible 190 document.addEventListener('visibilitychange', function() { 191 if (document.visibilityState === 'visible') { 192 isPageVisible = true; 193 } else { 194 isPageVisible = false;
195 } 196 }); 197 198 } 199 200} 201 202// Store random value 0-1 for persistent splitting 203function getUserSplitValue() { 204 const COOKIE_NAME = 'getmailbird_com_traffic_split_value'; 205 let value = readCookie(COOKIE_NAME); 206 if (!value) { 207 value = Math.random().toFixed(8); // save with precision 208 createCookie(COOKIE_NAME, value, 365); 209 } 210 return parseFloat(value); 211} 212 213// General function to check if user is in test group 214// Example: isInGroup(0.2) => true for 20% of users 215function isInGroup(percentage) { 216 const userValue = getUserSplitValue(); 217 return userValue < percentage; 218} 219 220/** 221* Attempts to download the app from Microsoft Store using direct download if possible, 222* otherwise gracefully falls back to opening the Store page. 223*/ 224async function downloadAppFromMSStore() { 225 /** 226 * Opens the Microsoft Store app as a fallback. 227 */ 228 function openStoreFallback(productId, ocid) { 229 // Try to open in the Microsoft Store app 230 window.location.href = `ms-windows-store://pdp/?productid=${productId}&ocid=${ocid}`; 231 } 232 233 /** 234 * Downloads a blob response as a file using a temporary anchor. 235 */ 236 async function downloadBlobAsFile(response, fallbackName) { 237 const contentDisposition = response.headers.get("Content-Disposition"); 238 let fileName = `${fallbackName} Installer.exe`; 239 240 if (contentDisposition) { 241 const match = contentDisposition.match(/filename\*=UTF-8''([\w%\-\.]*)/i); 242 if (match && match[1]) { 243 fileName = decodeURIComponent(match[1]); 244 } 245 } 246 247 if (!fileName.toLowerCase().endsWith(".exe")) { 248 fileName += ".exe"; 249 } 250 251 const blob = await response.blob(); 252 const blobUrl = URL.createObjectURL(blob); 253 254 const link = document.createElement("a"); 255 link.href = blobUrl; 256 link.download = fileName; 257 link.style.display = "none"; 258 document.body.appendChild(link); 259 260 try { 261 link.click(); 262 // Allow time for download to trigger before cleanup 263 await new Promise(resolve => setTimeout(resolve, 1000)); 264 } finally { 265 URL.revokeObjectURL(blobUrl); 266 document.body.removeChild(link); 267 } 268 } 269 270 const productId = "XP9KHKVP3JKR39"; 271 const productName = "Mailbird"; 272 const PSI_BASE_URL = "https://get.microsoft.com/installer/download/"; 273 const ocid = "psi_f_svc"; 274 275 const downloadUrl = `${PSI_BASE_URL}${productId.toUpperCase()}?referrer=appbadge&source=${encodeURIComponent(window.location.hostname.toLowerCase())}`; 276 277 try { 278 const response = await fetch(downloadUrl, { 279 method: "GET", 280 headers: { 281 Origin: "https://apps.microsoft.com", 282 Referer: document.URL, 283 "Access-Control-Request-Method": "GET", 284 "X-Correlation-Id": crypto.randomUUID(), 285 "Content-Type": "application/octet-stream" 286 }, 287 cache: "no-cache" 288 }); 289 290 if (response.ok) { 291 await downloadBlobAsFile(response, productName); 292 } else { 293 console.warn("Direct download failed, opening Store instead:", response.status); 294 openStoreFallback(productId, ocid); 295 } 296 } catch (error) { 297 console.error("Direct download attempt failed, opening Store instead:", error); 298 openStoreFallback(productId, ocid); 299 } 300} 301 302/* Handle downloading of Email Client */ 303async function downloadInstaller(offline = true, variation = '') { 304 const dllinks = { 305 'mac_universal_beta': 'https://links.getmailbird.com/mailbird_mac_universal_installer_beta', 306 'mac_universal': 'https://links.getmailbird.com/mailbird_mac_universal_installer', 307 'mac_arm64_ea': 'https://links.getmailbird.com/mailbird_mac_arm64_installer_early_adopters', 308 'mac_x86_64_ea': 'https://links.getmailbird.com/mailbird_mac_x86_64_installer_early_adopters', 309 'mac_arm64': 'https://links.getmailbird.com/mailbird_mac_arm64_installer', 310 'mac_x86_64': 'https://links.getmailbird.com/mailbird_mac_x86_64_installer', 311 'offline': 'https://goto.getmailbird.com/offline-installer', 312 'mb2offline': 'https://goto.getmailbird.com/mb2offline', 313 'mb3': 'https://goto.getmailbird.com/installer', 314 'mb2': 'https://goto.getmailbird.com/mb2', 315 'experimental': 'https://goto.getmailbird.com/xinstaller', 316 'alpha': 'https://goto.getmailbird.com/alphainstaller', 317 'msstore': 'https://goto.getmailbird.com/msstore', 318 'mac_app_store': 'https://goto.getmailbird.com/appleappstore', 319 'fallback': 'https://goto.getmailbird.com/installer' 320 } 321 322 // Fallback (default Windows Installer) 323 var shouldCheckMSStore = false;
324 var openNewTab = false; 325 var destinationUrl = dllinks.fallback; 326 if(variation == '') 327 variation = getParameterByName('variation'); 328 329 switch(variation) { 330 case 'mac_universal_beta': 331 destinationUrl = dllinks.mac_universal_beta; 332 break; 333 case 'mac_universal': 334 destinationUrl = dllinks.mac_universal; 335 break; 336 case 'mac_arm64_ea': 337 destinationUrl = dllinks.mac_arm64_ea; 338 break; 339 case 'mac_x86_64_ea': 340 destinationUrl = dllinks.mac_x86_64_ea; 341 break; 342 case 'mac_arm64': 343 destinationUrl = dllinks.mac_arm64; 344 break; 345 case 'mac_x86_64': 346 destinationUrl = dllinks.mac_x86_64; 347 break; 348 case 'offline': 349 destinationUrl = dllinks.offline; 350 break; 351 case 'mb2offline': 352 destinationUrl = dllinks.mb2offline; 353 break; 354 case 'mb3': 355 if(offline) { 356 destinationUrl = dllinks.offline; 357 variation = 'offline'; 358 } else { 359 destinationUrl = dllinks.mb3; 360 } 361 break; 362 case 'mb2': 363 if(offline) { 364 destinationUrl = dllinks.mb2offline; 365 variation = 'mb2offline'; 366 } else { 367 destinationUrl = dllinks.mb2; 368 } 369 break; 370 case 'alpha': 371 destinationUrl = dllinks.alpha; 372 break; 373 case 'experimental': 374 destinationUrl = dllinks.experimental; 375 break; 376 case 'mac_app_store': 377 destinationUrl = dllinks.mac_app_store; 378 openNewTab = true; 379 break; 380 case 'msstore': 381 destinationUrl = dllinks.msstore; 382 break; 383 case 'mac': 384 default: 385 destinationUrl = dllinks.fallback; 386 387 // We only execute this on demand 388 await loadReq('uaParser', 'https://www.getmailbird.com/assets/themes/mb1/js/ua-parser.min.js', 'script'); 389 390 // New download procedure logic 391 const uapresult = await UAParser().withClientHints(); 392 393 if (uapresult.os.name == 'macOS' || variation == 'mac') { 394 // 0% of users will be redirected to Mac App Store 395 if(isInGroup(0)) { 396 destinationUrl = dllinks.mac_app_store; 397 variation = 'mac_app_store'; 398 openNewTab = true; 399 } else { 400 destinationUrl = dllinks.mac_universal; 401 variation = 'mac_universal'; 402 } 403 } else { 404 shouldCheckMSStore = true; 405 if(offline) { 406 destinationUrl = dllinks.offline; 407 variation = 'offline'; 408 } else { 409 destinationUrl = dllinks.mb3; 410 variation = 'mb3'; 411 } 412 413 if(window.embed_mixpanel_to_installer) { 414 destinationUrl = 'https://www.getmailbird.com/download/?id=' + distinct_id; 415 shouldCheckMSStore = false; 416 } 417 } 418 break; 419 } 420 421 if(destinationUrl == dllinks.msstore || (shouldCheckMSStore && isInGroup(0))){ 422 variation = 'msstore'; 423 downloadAppFromMSStore(); 424 } 425 else { 426 if(openNewTab){ 427 // Open in new tab 428 window.open(destinationUrl, '_blank'); 429 } 430 else { 431 // Perform actual download 432 window.location = destinationUrl; 433 } 434 } 435 436 // The download has started 437 return variation; 438} 439 440/* Mixpanel Functions */ 441function initDistinctID(){ 442 distinct_id = getParameterByName('_mdi'); 443 if (!isBlankOrEmpty(distinct_id)){ 444 mixpanel.identify(distinct_id); 445 } else { 446 distinct_id = getUserId(); 447 } 448 449 createCookie("getmailbird_com_distinct_id_cookie", distinct_id, 3650); 450} 451 452 453function initUtmParamsTracking(){ 454 const excludeDomains = ['getmailbird.com', 'fastspring', 'mailbird', '127.0.0.1'];
455 const isExcluded = (domain) => excludeDomains.some(d => domain.includes(d)); 456 const cleanDomain = (url) => 457 url.replace(/^https?:\/\//, '') 458 .replace(/^www\./, '') 459 .split(/[/?#]/)[0]; 460 461 const getOrStore = (key, value) => { 462 if (isBlankOrEmpty(value)) { 463 return readCookie(key) || ""; 464 } else { 465 createCookie(key, value, 7); 466 return value; 467 } 468 }; 469 470 // Get Referrer Source 471 source = document.referrer; 472 if (!isBlankOrEmpty(source)) { 473 source = cleanDomain(source); 474 if (isExcluded(source)) source = ''; 475 } 476 477 // Get URL Parameters 478 utm_campaign = getParameterByName('utm_campaign'); 479 utm_source = getParameterByName('utm_source'); 480 utm_medium = getParameterByName('utm_medium'); 481 utm_term = getParameterByName('utm_term'); 482 utm_content = getParameterByName('utm_content'); 483 msclkid = getParameterByName('msclkid'); 484 gclid = getParameterByName('gclid'); 485 gbraid = getParameterByName('gbraid'); 486 wbraid = getParameterByName('wbraid'); 487 fbclid = getParameterByName('fbclid'); 488 ppsource = getParameterByName('ppsource'); 489 490 clickid = getParameterByName('clickid'); 491 irmpname = getParameterByName('irmpname'); 492 irpid = getParameterByName('irpid'); 493 494 // Store Parameters in Cookies 495 if (isCookieEnabled()) { 496 source = getOrStore("getmailbird_com_Source_cookie", source); 497 utm_campaign = getOrStore("getmailbird_com_Campaign_Name_cookie", utm_campaign); 498 utm_source = getOrStore("getmailbird_com_Campaign_Source_cookie", utm_source); 499 utm_medium = getOrStore("getmailbird_com_Campaign_Medium_cookie", utm_medium); 500 utm_term = getOrStore("getmailbird_com_Campaign_Term_cookie", utm_term); 501 utm_content = getOrStore("getmailbird_com_Campaign_Content_cookie", utm_content); 502 msclkid = getOrStore("getmailbird_com_msclkid_cookie", msclkid); 503 gclid = getOrStore("getmailbird_com_gclid_cookie", gclid); 504 gbraid = getOrStore("getmailbird_com_gbraid_cookie", gbraid); 505 wbraid = getOrStore("getmailbird_com_wbraid_cookie", wbraid); 506 fbclid = getOrStore("getmailbird_com_fbclid_cookie", fbclid); 507 508 clickid = getOrStore("getmailbird_com_gbraid_cookie", clickid); 509 irmpname = getOrStore("getmailbird_com_wbraid_cookie", irmpname); 510 irpid = getOrStore("getmailbird_com_fbclid_cookie", irpid); 511 } 512 513 // Attribution override for Bing/MS Ads 514 if (!isBlankOrEmpty(msclkid)) { 515 utm_medium = "cpc"; 516 utm_source = "bing"; 517 } 518 519 // Save first-touch URL 520 const url = [location.protocol, '//', location.host, location.pathname].join(''); 521 const firstTouchUrlCookieName = "getmailbird_com_FirstTouchUrl_cookie"; 522 const existing = readCookie(firstTouchUrlCookieName); 523 524 if (isCookieEnabled() && !isBlankOrEmpty(url) && (existing === null || existing.trim() === "")) { 525 createCookie(firstTouchUrlCookieName, url, 7); 526 } 527 528 // Save last-touch URL 529 const lastTouchUrlCookieName = "getmailbird_com_LastTouchUrl_cookie"; 530 const storefrontScript = document.querySelector('script[data-storefront*="onfastspring.com"]'); 531 if (!storefrontScript && !isBlankOrEmpty(url)) { 532 // We are not on the pricing page 533 createCookie(lastTouchUrlCookieName, url, 7); 534 } 535} 536 537function getPageTrackingProps() { 538 const body = document.body; 539 const classes = body.classList; 540 541 if (classes.contains('blog-template') && classes.contains('blog-single')) { 542 return { 543 'Page Type': 'Blog Article' 544 }; 545 } 546 547 if (classes.contains('setup-pages-template') && classes.contains('setup-pages-single')) { 548 return { 549 'Page Type': 'Setup Page', 550 'ESP': body.dataset.esp || null 551 }; 552 } 553 554 return { 555 'Page Type': 'Standard Page' 556 }; 557} 558 559function AfterMixpanelIsInitialized(){ 560 initDistinctID(); 561 initUtmParamsTracking(); 562 563 var url = [location.protocol, '//', location.host, location.pathname].join(''); 564 const firstTouchUrlCookieName = "getmailbird_com_FirstTouchUrl_cookie"; 565 const lastTouchUrlCookieName = "getmailbird_com_LastTouchUrl_cookie"; 566 const firstTouchUrl = readCookie(firstTouchUrlCookieName); 567 const lastTouchUrl = readCookie(lastTouchUrlCookieName); 568 569 const props = { 570 url, 571 'First Touch URL': firstTouchUrl, 572 'Last Touch URL': lastTouchUrl, 573 ...getPageTrackingProps() 574 }; 575 576 // Add "Downloaded Product" only if hostname and pathname match 577 if (['www.getmailbird.com', 'staging.getmailbird.com'].includes(location.hostname) && location.pathname.includes('/downloading/')) { 578 const params = new URLSearchParams(location.search); 579 const os = params.get('os'); 580 581 props['Downloaded Product'] = 582 os === 'macos' ? 'Mailbird for Mac' : 'Mailbird Classic'; 583 } 584 585 if (!excludeFromTracking()) { 586 mixpanel.track('Page viewed', props); 587 capturePostHog('Page viewed', props); 588 } 589} 590 591/* Mailbird for Mac Submission */ 592function subscribeMacRequester() { 593 let form_input = mb_for_mac_form.querySelector('input'); 594 let user_email = form_input.value.trim(); 595 let form_btn = mb_for_mac_form.querySelector('button'); 596 form_input.value = user_email; 597 form_input.disabled = true; 598 form_btn.setAttribute('disabled', ''); 599 if(user_email == "" || !validator.isEmail(user_email)){
600 alert(strings.email_not_valid); 601 form_input.disabled = false; 602 form_btn.removeAttribute('disabled', ''); 603 } else { 604 let postData = { 'email': user_email }; 605 fetch('https://links.getmailbird.com/webhook/3f5de33d-a8e1-4022-b27c-d8f6df05a27f', { 606 method: 'POST', 607 headers: { 608 "Content-Type": "application/json" 609 }, 610 body: JSON.stringify(postData) 611 }) 612 .then(response => response.json()) 613 .then(data => { 614 if(data.status == 'success') { 615 dataLayer.push({'event': 'eventTracking', 'category': 'Website', 'action': 'Sign up Mailbird for Mac', 'label': 'Website pages'}); 616 window.location.href = "https://getmailbird.typeform.com/to/BRJJ7cAm#email=" + user_email; 617 } else { 618 alert(strings.subscribe_fails); 619 form_input.disabled = false; 620 form_btn.removeAttribute('disabled', ''); 621 } 622 }) 623 .catch(error => { 624 alert(strings.general_error); 625 console.log(error); 626 }); 627 } 628} 629/* Mailbird for Mac Submission */ 630 631/* Send download link / Mobile Download Form */ 632function sendDownloadLink(){ 633 let form_input = mb_mobile_download_form.querySelector('input'); 634 let user_email = form_input.value.trim(); 635 let form_btn = mb_mobile_download_form.querySelector('button'); 636 form_input.value = user_email; 637 form_input.disabled = true; 638 form_btn.setAttribute('disabled', ''); 639 if(user_email == "" || !validator.isEmail(user_email)) { 640 alert(strings.email_not_valid); 641 form_input.disabled = false; 642 form_btn.removeAttribute('disabled', ''); 643 } else { 644 grecaptcha.enterprise.ready(async () => { 645 const token = await grecaptcha.enterprise.execute('6Lf4B5onAAAAAKIef9zZoswOLNYv2hKUyMVFP-I0', {action: 'mobile_download'}); 646 let postData = { 'email': user_email, 'token': token }; 647 648 fetch('https://links.getmailbird.com/webhook/dd2676f9-1705-4e4e-aa3e-919df35e262a', { 649 method: 'POST', 650 headers: { 651 "Content-Type": "application/json" 652 }, 653 body: JSON.stringify(postData) 654 }) 655 .then(response => response.json()) 656 .then(data => { 657 if(data.status == 'success') { 658 dataLayer.push({'event': 'eventTracking', 'category': 'Website', 'action': 'Sign up Mobile Form', 'label': 'Website pages'}); 659 alert(strings.download_link_sent); 660 form_input.disabled = false; 661 form_btn.removeAttribute('disabled', ''); 662 } else { 663 alert(strings.subscribe_fails); 664 form_input.disabled = false; 665 form_btn.removeAttribute('disabled', ''); 666 } 667 }) 668 .catch(error => { 669 alert(strings.general_error); 670 console.log(error); 671 }); 672 }); 673 } 674} 675/* Send download link / Mobile Download Form */ 676 677/* Handle WB Logic */ 678var wb = document.querySelector('#wbwrapper'); 679async function handleWB() { 680 wb.classList.add('invisible'); 681 document.querySelector('header').style.marginTop = '0px'; 682 document.querySelector('#mbmainmenu').style.marginTop = '0px'; 683 document.querySelector('#mb-banner-right').classList.add('d-none', 'd-lg-block'); 684 685 if(wb && window.innerWidth >= 992) { 686 wb.classList.add('top-0', 'w-100'); 687 wb.classList.remove('bottom-0', 'mb-2'); 688 wb.removeEventListener('click', redirecttourl); 689 document.querySelector('#toastwb').classList.add('border-0', 'rounded-0', 'w-100', 'm-0'); 690 document.querySelector('#mb-banner').classList.add('py-2'); 691 document.querySelector('#mb-banner-left').classList.add('fs-5'); 692 document.querySelector('#mb-banner-middle').classList.add('fs-3'); 693 document.querySelector('#toastwb').classList.remove('border-2', 'rounded-2', 'border-warning'); 694 while (wb.clientHeight <= 0) { 695 await new Promise(r => setTimeout(r, 100)); 696 } 697 document.querySelector('header').style.marginTop = wb.clientHeight + 'px'; 698 document.querySelector('#mbmainmenu').style.marginTop = wb.clientHeight + 'px'; 699 wb.style.cursor = 'auto'; 700 wb.classList.remove('invisible'); 701 } else { 702 if(readCookie("getmailbird_com_navbar_cookie_closed_cookie")) { 703 showmobilewb(); 704 } else { 705 wb.classList.add('invisible'); 706 document.querySelector('#mb-footer-lawmsg').querySelectorAll('button').forEach(el => { 707 el.addEventListener('click', showmobilewb); 708 }) 709 wb.removeEventListener('click', redirecttourl); 710 } 711 } 712} 713 714function showmobilewb() { 715 wb.classList.add('bottom-0', 'mb-2'); 716 document.querySelector('#toastwb').classList.add('border-2', 'rounded-2', 'border-warning'); 717 document.querySelector('#toastwb').classList.remove('border-0', 'rounded-0', 'w-100', 'm-0'); 718 document.querySelector('#mb-banner').classList.remove('py-2'); 719 document.querySelector('#mb-banner-left').classList.remove('fs-5');
720 document.querySelector('#mb-banner-middle').classList.remove('fs-3'); 721 wb.style.cursor = 'pointer'; 722 wb.classList.remove('top-0', 'w-100', 'invisible'); 723 wb.addEventListener('click', redirecttourl); 724} 725 726function redirecttourl() { 727 if(document.querySelector(".buy-now").getAttribute('data-href')) { 728 window.location = document.querySelector(".buy-now").getAttribute('data-href'); 729 } else { 730 window.location = document.querySelector("a.buy-btn").href; 731 } 732} 733/* Handle WB Logic */ 734 735 736/* Global / Common Functions */ 737function isBlankOrEmpty(str) { 738 return (!str || /^\s*$/.test(str) || 0 === str.length); 739} 740 741function getParameterByName(name) { 742 name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); 743 var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), 744 results = regex.exec(location.search); 745 return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); 746} 747 748async function hashSHA256(message) { 749 const encoder = new TextEncoder(); 750 const data = encoder.encode(message); 751 const hashBuffer = await crypto.subtle.digest("SHA-256", data); 752 const hashArray = Array.from(new Uint8Array(hashBuffer)); 753 const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); 754 return hashHex; 755} 756 757function getUserId() { 758 var id = ""; 759 var reidentify = false; 760 try { 761 if (isCookieEnabled() && readCookie("getmailbird_com_distinct_id_cookie") != null) 762 { 763 id = readCookie("getmailbird_com_distinct_id_cookie"); 764 reidentify = id != mixpanel.get_distinct_id(); 765 } 766 else 767 id = mixpanel.get_distinct_id(); 768 } 769 catch (err) { 770 id = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { 771 var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8); 772 return v.toString(16); 773 }); 774 reidentify = true; 775 } 776 777 try { 778 if(reidentify) 779 mixpanel.identify(id); 780 } catch (err) { } 781 782 return id; 783} 784 785function excludeFromTracking() { 786 // Normalize UA string to lowercase 787 const ua = navigator.userAgent.toLowerCase(); 788 789 // Common crawlers, bots, and auditing tools 790 const blacklist = [ 791 // SEO tools / audits 792 "ahrefssiteaudit", "ahrefsbot", "semrushbot", "chrome-lighthouse", 793 "rogerbot", "mj12bot", "dotbot", 794 795 // Major search engines 796 "googlebot", "bingbot", "slurp", "duckduckbot", 797 "baiduspider", "yandexbot", "sogou", "exabot", 798 "petalbot", "seznambot", "naverbot", "qwantify", 799 800 // Social media bots 801 "facebot", "twitterbot", "linkedinbot", "pinterestbot", "whatsapp", 802 803 // Generic catch-alls 804 "crawler", "spider", "robot" 805 ]; 806 807 return blacklist.some(bot => ua.includes(bot)); 808} 809 810// Include our required files 811function loadReq(id, url, type = 'script') { 812 return new Promise(function(resolve, reject) { 813 var resource; 814 var head = document.head; 815 switch(type) { 816 case 'script': 817 var script = document.createElement('script'); 818 script.id = id; 819 script.type = 'text/javascript'; 820 script.src = url; 821 script.onload = () => resolve(script); 822 script.onerror = () => reject(new Error(`Script load error for ${src}`)); 823 resource = script; 824 break; 825 case 'css': 826 var link = document.createElement('link'); 827 link.id = id; 828 link.rel = 'stylesheet'; 829 link.type = 'text/css'; 830 link.href = url; 831 link.media = 'all'; 832 link.onload = () => resolve(script); 833 link.onerror = () => reject(new Error(`CSS load error for ${src}`)); 834 resource = link; 835 break; 836 } 837 838 head.appendChild(resource); 839 }); 840} 841 842function subscribeToBlog(subscribeform) { 843 let form_input = subscribeform.querySelector('#blogemailaddr'); 844 let form_btn = subscribeform.querySelector('button'); 845 let user_email = form_input.value; 846 let list = [ "0081dc31-7c41-44dd-9baa-695c1f1b13c4" ]; 847 let checkbox = document.querySelectorAll('input[name="list"]:checked'); 848 // Disable form fields while submitting 849 form_input.disabled = true; 850 form_btn.setAttribute('disabled', ''); 851 if(user_email == "" || !validator.isEmail(user_email)){
852 alert(strings.email_not_valid); 853 } else { 854 // We're ready for the remaining logic 855 checkbox.forEach(function(cat) { 856 list.push(cat.value); 857 }); 858 grecaptcha.enterprise.ready(async () => { 859 const token = await grecaptcha.enterprise.execute('6Lf4B5onAAAAAKIef9zZoswOLNYv2hKUyMVFP-I0', {action: 'subscribe_newsletter'}); 860 let fetchurl = 'https://links.getmailbird.com/webhook/aa55073b-3557-4999-8b10-7e12893eb964'; 861 let postData = { 'type': 'newsletter', 'origin': 'Website', 'email': user_email, 'list': list.join(","), 'token': token }; 862 fetch(fetchurl, { 863 method: 'POST', 864 headers: { 865 "Content-Type": "application/json" 866 }, 867 body: JSON.stringify(postData) 868 }) 869 .then(response => { 870 if(response.status == 200) { 871 alert(strings.subscription_success); 872 } else { 873 alert(strings.subscription_failure); 874 } 875 //console.log(fetchurl); 876 }) 877 // We will ideally setup an actual json response in this endpoint 878 // .then(response => response.json()) 879 // .then(data => { 880 // }) 881 .catch(error => { 882 alert(strings.general_error); 883 console.log(error); 884 }); 885 }); 886 } 887 // Re-enable form fields after everything is done 888 form_input.disabled = false; 889 form_btn.removeAttribute('disabled', ''); 890} 891 892function prepareVP() { 893 894 // define page monitors and their respective elements 895 const elMonitor = { 896 'body.pricing' : ['#wbppendsin', '#mb-footer-lawmsg', 'iframe#launcher', '#downloadsNumHolder', '.mac-ventura-banner-content', '.last-sold', '.last-sold', '.last-sold'], // Pricing Page 897 'body.blog-single' : ['#mb-timer', '#mb-footer-lawmsg'], // Blog Post Single 898 'body.tpl_3' : ['#mb-timer', '#mb-footer-lawmsg', '#downloadsNumHolder', '.embla__viewport'], // Homepage 899 'body.tpl_40' : ['#mb-footer-lawmsg', '#downloadsNumHolder'], // Installation Confirmation 900 'body.tpl_22' : ['#mb-timer', '#mb-footer-lawmsg'], // Continue to Mailbird 901 'body.tpl_64' : ['#mb-footer-lawmsg', '#block-pricingboxes-late-2024 .ft-desc:first-of-type'], // Upgrade Page 902 }; 903 904 Object.keys(elMonitor).forEach(k => { 905 if(document.querySelector(k)) { 906 elMonitor[k].forEach((el) => { 907 if(document.querySelector(el)) { 908 document.querySelector(el).remove(); 909 } 910 }); 911 } 912 }); 913 914 // Force recreation of WB cookie and make it 48 hours instead 915 createCookie('getmailbird_com_banner_cookie', (new Date().getTime() / 999), 3650); 916 917} 918/* Global / Common Functions */
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.