PageSourceSearch

https://www.betterbrain.com/marketing-integrations/b5e3f1804d49.js

js betterbrain.com collected 2026-09-28 08:34:20 UTC 2,498 bytes, 67 lines download raw bytes

1
2(function () {
3  // ---- Pages that START a journey → their nav mode. Add new landing slugs here. ----
4  var ORIGINS = {
5    '/insurance':    'insurance',
6    '/blueprint':    'blueprint',
7    '/bb-blueprint': 'blueprint',
8    '/blueprint-direct': 'blueprint-direct',
9    '/ptau':         'ptau'
10    // '/ptau217': 'ptau', '/employers': 'employers'  // add if those are landing origins
11  };
12
13  var path    = location.pathname.replace(/\/+$/, '') || '/';
14  var navMode = new URLSearchParams(location.search).get('nav');
15  var home = null, mode = null;
16
17  if (ORIGINS[path]) {
18    // On an origin page → identity is known from the path, no param needed
19    home = path;
20    mode = ORIGINS[path];
21    try {
22      sessionStorage.setItem('navHome', home);
23      sessionStorage.setItem('navMode', mode);
24    } catch (e) {}
25  } else if (navMode) {
26    // Intermediate page, mid-journey → use the remembered origin
27    try { home = sessionStorage.getItem('navHome'); mode = sessionStorage.getItem('navMode'); } catch (e) {}
28    if (!home || mode !== navMode) {
29      var FALLBACK = { insurance: '/insurance', ptau: '/ptau', blueprint: '/blueprint', 'blueprint-direct': '/blueprint-direct' };
30      home = FALLBACK[navMode]; mode = navMode;
31    }
32  }
33
34  if (!home || !mode) return;   // not in a journey → leave the logo alone
35
36  var target   = home + '?nav=' + mode;
37  var SELECTOR = 'a.nav_logo-link, a.footer_logo-link';
38
39  // Keep the logo href correct even if other scripts overwrite it
40  function enforce() {
41    document.querySelectorAll(SELECTOR).forEach(function (a) {
42      if (a.getAttribute('href') !== target) a.setAttribute('href', target);
43    });
44  }
45  (document.readyState !== 'loading') ? enforce()
46    : document.addEventListener('DOMContentLoaded', enforce);
47  setTimeout(enforce, 400);
48  setTimeout(enforce, 1300);
49  try {
50    new MutationObserver(enforce).observe(document.documentElement, {
51      subtree: true, childList: true, attributes: true, attributeFilter: ['href']
52    });
53  } catch (e) {}
54
55  // Guarantee the destination on a plain click; leave new-tab clicks to the browser
56  document.addEventListener('click', function (e) {
57    var a = e.target && e.target.closest ? e.target.closest(SELECTOR) : null;
58    if (!a) return;
59    if (e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) {
60      a.setAttribute('href', target);
61      return;
62    }
63    e.preventDefault();
64    e.stopImmediatePropagation();
65    location.assign(target);
66  }, true);
67})();

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.