PageSourceSearch

https://fairland.com.cn/template/default/js/privacy-policy-notice.js?v=20260923

js fairland.com.cn collected 2026-10-01 14:17:12 UTC 2,728 bytes, 105 lines download raw bytes

1(function () {
2  "use strict";
3
4  var config = Object.freeze({
5    storageKey: "privacy_policy_notice_ack",
6    policyVersion: "2026-09-23",
7    campaignStartAt: "2026-09-23T09:00:00+08:00",
8    displayDurationDays: 60,
9    privacyPolicyUrl: "/privacy-policy",
10  });
11
12  var visibleClass = "privacy-policy-notice-visible";
13  var millisecondsPerDay = 24 * 60 * 60 * 1000;
14
15  function getCampaignWindow() {
16    if (
17      !config.policyVersion ||
18      !config.campaignStartAt ||
19      !config.privacyPolicyUrl ||
20      typeof config.displayDurationDays !== "number" ||
21      !isFinite(config.displayDurationDays) ||
22      config.displayDurationDays <= 0
23    ) {
24      return null;
25    }
26
27    var startAt = Date.parse(config.campaignStartAt);
28    var endAt = startAt + config.displayDurationDays * millisecondsPerDay;
29
30    if (!isFinite(startAt) || !isFinite(endAt)) {
31      return null;
32    }
33
34    return {
35      startAt: startAt,
36      endAt: endAt,
37    };
38  }
39
40  function getAcknowledgedVersion() {
41    try {
42      return window.localStorage.getItem(config.storageKey);
43    } catch (error) {
44      return null;
45    }
46  }
47
48  function saveAcknowledgedVersion() {
49    try {
50      window.localStorage.setItem(config.storageKey, config.policyVersion);
51      return true;
52    } catch (error) {
53      return false;
54    }
55  }
56
57  function hideNotice(notice) {
58    document.documentElement.classList.remove(visibleClass);
59    notice.setAttribute("aria-hidden", "true");
60  }
61
62  var campaignWindow = getCampaignWindow();
63  var now = Date.now();
64  var shouldShow = Boolean(
65    campaignWindow &&
66      now >= campaignWindow.startAt &&
67      now < campaignWindow.endAt &&
68      getAcknowledgedVersion() !== config.policyVersion
69  );
70
71  if (shouldShow) {
72    document.documentElement.classList.add(visibleClass);
73  } else {
74    document.documentElement.classList.remove(visibleClass);
75  }
76
77  document.addEventListener("DOMContentLoaded", function () {
78    var notice = document.querySelector(".privacy-policy-notice");
79
80    if (!notice || !shouldShow) {
81      document.documentElement.classList.remove(visibleClass);
82      return;
83    }
84
85    var learnMoreLink = notice.querySelector("[data-privacy-policy-notice-link]");
86    var closeButton = notice.querySelector("[data-privacy-policy-notice-close]");
87
88    if (!learnMoreLink || !closeButton) {
89      hideNotice(notice);
90      return;
91    }
92
93    learnMoreLink.setAttribute("href", config.privacyPolicyUrl);
94    notice.setAttribute("aria-hidden", "false");
95
96    learnMoreLink.addEventListener("click", function () {
97      saveAcknowledgedVersion();
98    });
99
100    closeButton.addEventListener("click", function () {
101      saveAcknowledgedVersion();
102      hideNotice(notice);
103    });
104  });
105})();

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.