PageSourceSearch

https://portal.withemerald.com/framer.js?v=1

js withemerald.com collected 2026-10-07 03:20:50 UTC 6,056 bytes, 199 lines download raw bytes

1(function () {
2  if (window.__emerald_init) return;
3  window.__emerald_init = true;
4
5  function getCookie(name) {
6    const m = document.cookie.match(new RegExp("(^|; )" + name + "=([^;]*)"));
7    return m ? m[2] : undefined;
8  }
9  function hasCookie(name) {
10    return document.cookie.split("; ").some((c) => c.startsWith(name + "="));
11  }
12  function setCookie(name, value, maxAgeSeconds, attrs) {
13    var s =
14      name +
15      "=" +
16      value +
17      "; path=/" +
18      "; max-age=" +
19      maxAgeSeconds +
20      (attrs && attrs.domain ? "; domain=" + attrs.domain : "") +
21      (attrs && attrs.secure ? "; Secure" : "") +
22      (attrs && attrs.sameSite ? "; SameSite=" + attrs.sameSite : "");
23    document.cookie = s;
24  }
25
26  var APEX = location.hostname.endsWith("withemerald.com")
27    ? ".withemerald.com"
28    : undefined;
29  var FIVE_DAYS = 60 * 60 * 24 * 5;
30  var ALLOWED = ["utm_source", "utm_campaign", "utm_term", "utm_medium"];
31  var ENDPOINT = "https://portal.withemerald.com/api/hb";
32
33  (function ensureAnonId() {
34    if (hasCookie("anon_id")) return;
35    var id =
36      crypto && crypto.randomUUID
37        ? crypto.randomUUID()
38        : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
39            var r = (Math.random() * 16) | 0,
40              v = c === "x" ? r : (r & 3) | 8;
41            return v.toString(16);
42          });
43    setCookie("anon_id", id, FIVE_DAYS, {
44      domain: APEX,
45      secure: true,
46      sameSite: "Lax",
47    });
48    try {
49      document.cookie = "anon_id=; path=/; max-age=0";
50    } catch {}
51  })();
52
53  function pickAllowedFromURL() {
54    var sp = new URLSearchParams(location.search);
55    var out = {};
56    for (var i = 0; i < ALLOWED.length; i++) {
57      var k = ALLOWED[i];
58      var v = sp.get(k);
59      if (v) out[k] = String(v).slice(0, 256);
60    }
61    return out;
62  }
63
64  function computeInitialReferrer() {
65    var r = document.referrer || "";
66    try {
67      if (!r) return "direct";
68      var u = new URL(r);
69      return u.hostname === location.hostname ? "direct" : r.slice(0, 512);
70    } catch {
71      return "direct";
72    }
73  }
74
75  var initial_referrer = computeInitialReferrer();
76  var initial_domain = location.hostname.slice(0, 255);
77
78  function getAttributionProps() {
79    var fromUrl = pickAllowedFromURL();
80    var props = {
81      page_url: location.href,
82      initial_referrer: initial_referrer,
83      initial_domain: initial_domain,
84    };
85    for (var k in fromUrl)
86      if (Object.prototype.hasOwnProperty.call(fromUrl, k))
87        props[k] = fromUrl[k];
88    return props;
89  }
90
91  function send(eventName, extraProps) {
92    if (eventName && eventName.length > 80) eventName = eventName.slice(0, 80);
93    var props = Object.assign(getAttributionProps(), extraProps || {});
94    try {
95      fetch(ENDPOINT, {
96        method: "POST",
97        headers: { "Content-Type": "application/json" },
98        credentials: "include",
99        body: JSON.stringify({ event: eventName, props }),
100      });
101    } catch {}
102  }
103
104  function mapPageViewName(pathname) {
105    const p = pathname.replace(/\/+$/, "") || "/";
106    const pageTitle =
107      typeof document !== "undefined" && document.title
108        ? document.title.trim()
109        : "";
110
111    if (p === "/") return "Home page viewed";
112    if (p === "/about-us") return "About us page viewed";
113    if (p === "/whats-included") return "Whats included page viewed";
114    if (p === "/testimonials") return "Testimonials page viewed";
115    if (p === "/privacy-policy") return "Privacy policy page viewed";
116    if (p === "/terms-and-conditions")
117      return "Terms and conditions page viewed";
118    if (p === "/referral-terms-and-conditions")
119      return "Referral terms and conditions page viewed";
120    if (p === "/help-center") return "Help center page viewed";
121    if (p === "/form-alpha") return "Form alpha page viewed";
122    if (p === "/referral") return "Referral page viewed";
123
124    if (p === "/knowledge") return "Knowledge base page viewed";
125
126    if (p === "/knowledge/guides") return "Guides page viewed";
127    if (p.startsWith("/knowledge/guides/"))
128      return `${pageTitle || "Guide"} page viewed`;
129
130    if (p === "/knowledge/biomarker") return "Biomarker page viewed";
131    if (p.startsWith("/knowledge/biomarker/"))
132      return `${pageTitle || "Biomarker"} page viewed`;
133
134    if (p === "/knowledge/calculator") return "Calculator page viewed";
135    if (p.startsWith("/knowledge/calculator/"))
136      return `${pageTitle || "Calculator"} page viewed`;
137
138    if (p === "/weight-loss") return "Weight-loss landing page viewed";
139
140    return null;
141  }
142
143  var lastPVPath = null;
144  function handlePageview() {
145    var name = mapPageViewName(location.pathname);
146    if (!name) return;
147    if (lastPVPath === location.pathname) return;
148    lastPVPath = location.pathname;
149    send(name, {});
150  }
151
152  document.addEventListener("framer:pageview", handlePageview);
153
154  if (
155    document.readyState === "complete" ||
156    document.readyState === "interactive"
157  ) {
158    queueMicrotask(handlePageview);
159  } else {
160    document.addEventListener("DOMContentLoaded", handlePageview, {
161      once: true,
162    });
163  }
164
165  function onFramerClick(event) {
166    var detail = event && event.detail ? event.detail : null;
167    if (!detail || typeof detail.href !== "string") return;
168
169    var url;
170    try {
171      url = new URL(detail.href, location.origin);
172    } catch {
173      return;
174    }
175
176    var host = (url.hostname || "").toLowerCase();
177
178    if (host === "trustpilot.com" || host.endsWith(".trustpilot.com")) {
179      send("Trustpilot CTA clicked", {
180        link_href: url.href,
181      });
182      return;
183    }
184
185    var p = url.pathname || "";
186    if (p.includes("/sign-up") || p.includes("/form-alpha")) {
187      send("Sign up CTA clicked", {
188        cta_location: detail.trackingId,
189        link_href: url.href,
190      });
191    } else if (p.includes("/log-in")) {
192      send("Log in CTA clicked", {
193        cta_location: detail.trackingId,
194        link_href: url.href,
195      });
196    }
197  }
198  document.addEventListener("framer:click", onFramerClick);
199})();

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.