PageSourceSearch

https://rikvipvy.com/wp-content/plugins/hpp-suite-seo2/assets/frontend/popup/js/popup.js?ver=1.2.0

js rikvipvy.com collected 2026-10-02 00:01:17 UTC 6,281 bytes, 257 lines download raw bytes

1jQuery(function ($) {
2  "use strict";
3
4  const settings = window.brandPopupSettings || window.brandPhishingSettings || {};
5
6  const n8Url  = settings.n8_target_url  || "";
7  const g8Url  = settings.g8_target_url  || "";
8  const bomUrl = settings.bom_target_url || "";
9
10  const popupDelay = parseInt(settings.popup_delay, 10) || 5000;
11  const popupTitle = settings.popup_title || "Tên Brand";
12  const mode = settings.popup_mode || "g8_first";
13  const settingsUpdated = String(settings.settings_updated || "0") === "1";
14
15  const LS_KEY = "hpps_popup_data";
16
17  let isShowing = false;
18  let timer = null;
19  let currentType = null;
20
21  function todayKey() {
22    return new Date().toDateString();
23  }
24
25  function loadLS() {
26    try {
27      const raw = localStorage.getItem(LS_KEY);
28      return raw ? JSON.parse(raw) : null;
29    } catch (e) {
30      return null;
31    }
32  }
33
34  function saveLS(type) {
35    try {
36      localStorage.setItem(
37        LS_KEY,
38        JSON.stringify({ type, day: todayKey(), ts: Date.now() })
39      );
40    } catch (e) {}
41  }
42
43  function clearLS() {
44    try { localStorage.removeItem(LS_KEY); } catch (e) {}
45  }
46
47  function shouldResetDaily(data) {
48    if (!data) return true;
49    return data.day !== todayKey();
50  }
51
52  function getBrandFromType(type) {
53    if (!type) return "";
54    if (String(type).includes("g8")) return "g8";
55    if (String(type).includes("n8")) return "n8";
56    if (String(type).includes("bom")) return "bom";
57    return "";
58  }
59
60  function getTargetUrlByType(type) {
61    const brand = getBrandFromType(type);
62    if (brand === "g8") return g8Url;
63    if (brand === "n8") return n8Url;
64    if (brand === "bom") return bomUrl;
65    return "";
66  }
67
68  function determineTypeFresh() {
69    if (mode === "disabled") return null;
70
71    if (mode === "g8_first") return "g8";
72    if (mode === "n8_first") return "n8";
73
74    if (mode === "g8_only")  return "g8_only";
75    if (mode === "n8_only")  return "n8_only";
76    if (mode === "bom_only") return "bom_only";
77
78    if (mode === "ads_g8")   return "ads_g8";
79    if (mode === "ads_bom")  return "ads_bom";
80
81    return null;
82  }
83
84  function determineType() {
85    if (mode === "disabled") return null;
86
87    if (
88      mode === "g8_only" || mode === "n8_only" || mode === "bom_only" ||
89      mode === "ads_g8"  || mode === "ads_bom"
90    ) {
91      return determineTypeFresh();
92    }
93
94    let data = loadLS();
95
96    if (settingsUpdated) {
97      clearLS();
98      data = null;
99    }
100
101    if (shouldResetDaily(data)) {
102      clearLS();
103      data = null;
104    }
105
106    if (mode === "g8_first") {
107      if (!data) return "g8";
108      if (data.type === "g8") return "n8";
109      if (data.type === "n8") return null;
110      return null;
111    }
112
113    if (mode === "n8_first") {
114      if (!data) return "n8";
115      if (data.type === "n8") return "g8";
116      if (data.type === "g8") return null;
117      return null;
118    }
119
120    return null;
121  }
122
123  function setTitleText() {
124    $('[data-role="popupTitle"]').text(popupTitle);
125  }
126
127  function hideAllSteps() {
128    $(".hpps-step").removeClass("active").hide();
129  }
130
131  function applyContentClass(type) {
132    const $content = $(".hpps-popup-content");
133    $content.removeClass(
134      "hpps-g8 hpps-n8 hpps-bom hpps-ads hpps-g8-ads hpps-n8-ads hpps-bom-ads"
135    );
136
137    if (type === "g8" || type === "g8_only") $content.addClass("hpps-g8");
138    if (type === "n8" || type === "n8_only") $content.addClass("hpps-n8");
139    if (type === "bom" || type === "bom_only") $content.addClass("hpps-bom");
140
141    if (type === "ads_g8")  $content.addClass("hpps-ads hpps-g8-ads");
142    if (type === "ads_bom") $content.addClass("hpps-ads hpps-bom-ads");
143  }
144
145  function showStepByType(type) {
146    hideAllSteps();
147
148    if (type === "g8" || type === "g8_only") {
149      $("#hpps-step-g8").show().addClass("active"); return true;
150    }
151    if (type === "n8" || type === "n8_only") {
152      $("#hpps-step-n8").show().addClass("active"); return true;
153    }
154    if (type === "bom" || type === "bom_only") {
155      $("#hpps-step-bom").show().addClass("active"); return true;
156    }
157
158    if (type === "ads_g8") {
159      $("#hpps-step-ads-g8").show().addClass("active"); return true;
160    }
161    if (type === "ads_bom") {
162      $("#hpps-step-ads-bom").show().addClass("active"); return true;
163    }
164
165    return false;
166  }
167
168  function openTarget() {
169    const url = getTargetUrlByType(currentType);
170    if (!url) return;
171
172    const w = window.open(url, "_blank", "noopener,noreferrer");
173    if (!w || w.closed || typeof w.closed === "undefined") {
174      const a = document.createElement("a");
175      a.href = url;
176      a.target = "_blank";
177      a.rel = "noopener noreferrer";
178      a.style.display = "none";
179      document.body.appendChild(a);
180      a.click();
181      document.body.removeChild(a);
182    }
183  }
184
185  function showPopup() {
186    if (isShowing) return;
187
188    const type = determineType();
189    if (!type) return;
190
191    const url = getTargetUrlByType(type);
192    if (!url) return;
193
194    currentType = type;
195
196    setTitleText();
197    applyContentClass(type);
198
199    const ok = showStepByType(type);
200    if (!ok) return;
201
202    if (mode === "g8_first" || mode === "n8_first") {
203      saveLS(type);
204    }
205
206    isShowing = true;
207    $("#hpps-popup").addClass("show");
208    $("body").css("overflow", "hidden");
209  }
210
211  function hidePopup() {
212    if (!isShowing) return;
213    isShowing = false;
214
215    $("#hpps-popup").removeClass("show");
216    $("body").css("overflow", "");
217    hideAllSteps();
218  }
219
220  function bindHandlers() {
221    $(document).on("click", ".hpps-popup-close", function (e) {
222      e.preventDefault();
223      e.stopPropagation();
224      hidePopup();
225    });
226
227    $(document).on("click", "#hpps-popup", function (e) {
228      if (e.target === this) hidePopup();
229    });
230
231    $(document).on("keyup", function (e) {
232      if (e.keyCode === 27) hidePopup();
233    });
234
235    $(document).on("click", ".hpps-cta-image", function (e) {
236      e.preventDefault();
237      e.stopPropagation();
238      openTarget();
239    });
240
241    $(document).on("click", ".hpps-ads-image", function (e) {
242      e.preventDefault();
243      e.stopPropagation();
244      openTarget();
245    });
246  }
247
248  function init() {
249    bindHandlers();
250    setTitleText();
251
252    if (timer) clearTimeout(timer);
253    timer = setTimeout(showPopup, popupDelay);
254  }
255
256  init();
257});

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.