PageSourceSearch

https://longevity-protocols.com/js/hide-pro-docs.js

js longevity-protocols.com collected 2026-10-07 18:54:49 UTC 3,424 bytes, 117 lines download raw bytes

1function hideLoader() {
2  const loader = document.querySelector("#proContentLoader");
3  if (loader) {
4    loader.style.display = "none";
5  }
6}
7
8export function hideProDocs(userData) {
9  const { docs_content_pro } = CONFIG;
10
11  // If paywall is disabled, show everything and hide paywall/loader.
12  if (!docs_content_pro) {
13    const paywallCta = document.querySelector("#proContentPaywall");
14    if (paywallCta) {
15      paywallCta.style.display = "none";
16    }
17
18    const protectedContents = document.querySelectorAll(".pro-content");
19    protectedContents.forEach((protectedContent) => {
20      protectedContent.style.display = "block";
21    });
22
23    hideLoader();
24    return;
25  }
26
27  if (userData.isPro) {
28    document.querySelectorAll(".cv-pro-example").forEach(function (el) {
29      const docFrag = document.createDocumentFragment();
30      while (el.firstChild) {
31        const child = el.removeChild(el.firstChild);
32        docFrag.appendChild(child);
33      }
34      el.parentNode.replaceChild(docFrag, el);
35    });
36
37    if (docs_content_pro) {
38      // Hide paywall CTA for PRO users
39      const paywallCta = document.querySelector("#proContentPaywall");
40      if (paywallCta) {
41        paywallCta.style.display = "none";
42      }
43
44      hideLoader();
45
46      // Show protected content for PRO users
47      const protectedContents = document.querySelectorAll(".pro-content");
48      protectedContents.forEach((protectedContent) => {
49        protectedContent.style.display = "block";
50      });
51    }
52  } else {
53    // Show the paywall CTA
54    const paywallCta = document.querySelector("#proContentPaywall");
55    if (paywallCta) {
56      paywallCta.style.display = "block";
57    }
58
59    hideLoader();
60
61    // Hide protected content
62    const protectedContents = document.querySelectorAll(".pro-content");
63    protectedContents.forEach((protectedContent) => {
64      protectedContent.style.display = "none";
65    });
66  }
67}
68
69const PENDING_EMAIL_CONFIRMATION_KEY = "pendingEmailConfirmation";
70
71export function setPendingEmailConfirmation() {
72  try {
73    sessionStorage.setItem(PENDING_EMAIL_CONFIRMATION_KEY, "1");
74  } catch (_) {}
75}
76
77export function clearPendingEmailConfirmation() {
78  try {
79    sessionStorage.removeItem(PENDING_EMAIL_CONFIRMATION_KEY);
80  } catch (_) {}
81}
82
83export function hasPendingEmailConfirmation() {
84  try {
85    return !!sessionStorage.getItem(PENDING_EMAIL_CONFIRMATION_KEY);
86  } catch (_) {
87    return false;
88  }
89}
90
91export function updateAcademyAppPaywall(userData) {
92  const container = document.getElementById("academy-app-paywall");
93  if (!container) return;
94
95  const formsBlock = document.getElementById("academy-paywall-forms");
96  const msgLoggedIn = document.getElementById("academy-paywall-message-logged-in");
97  const msgPending = document.getElementById("academy-paywall-message-pending-confirmation");
98
99  if (!formsBlock || !msgLoggedIn || !msgPending) return;
100
101  const isLoggedIn = userData && userData.isLoggedIn === true;
102  const pendingConfirm = hasPendingEmailConfirmation();
103
104  if (isLoggedIn) {
105    formsBlock.style.display = "none";
106    msgLoggedIn.style.display = "block";
107    msgPending.style.display = "none";
108  } else if (pendingConfirm) {
109    formsBlock.style.display = "none";
110    msgLoggedIn.style.display = "none";
111    msgPending.style.display = "block";
112  } else {
113    formsBlock.style.display = "";
114    msgLoggedIn.style.display = "none";
115    msgPending.style.display = "none";
116  }
117}

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.