PageSourceSearch

https://www.hydemedspa.com/hyde-formsubmit.js

js hydemedspa.com collected 2026-09-24 13:12:42 UTC 4,316 bytes, 115 lines download raw bytes

1(() => {
2  "use strict";
3
4  const endpoint = "https://formsubmit.co/2a5d9fa106f3e1c89b6e6658e681c892";
5  const dropNames = new Set([
6    "wsite_subject",
7    "form_version",
8    "wsite_approved",
9    "ucfid",
10    "recaptcha_token",
11    "bn"
12  ]);
13
14  function cleanText(value) {
15    return String(value || "")
16      .replace(/\u00a0/g, " ")
17      .replace(/\s*\*\s*$/g, "")
18      .replace(/\s+/g, " ")
19      .trim();
20  }
21
22  function friendlyName(raw) {
23    const text = cleanText(raw).toLowerCase();
24    if (!text) return "";
25    if (text.includes("first") && text.includes("name")) return "First Name";
26    if (text.includes("last") && text.includes("name")) return "Last Name";
27    if (text.includes("phone") || text.includes("mobile") || text.includes("cell")) return "Phone Number";
28    if (text.includes("email")) return "Email";
29    if (text.includes("help") || text.includes("message") || text.includes("comment")) return "Message";
30    if (text.includes("sms") || text.includes("text message") || text.includes("opt")) return "SMS Consent";
31    if (text === "name") return "Name";
32    return cleanText(raw).replace(/[^\w\s-]/g, "").trim();
33  }
34
35  function addHidden(form, name, value) {
36    let input = form.querySelector('input[type="hidden"][name="' + name + '"]');
37    if (!input) {
38      input = document.createElement("input");
39      input.type = "hidden";
40      input.name = name;
41      form.appendChild(input);
42    }
43    input.value = value;
44  }
45
46  function prepareForm(form) {
47    const labels = new Map();
48    for (const label of form.querySelectorAll("label[for]")) {
49      labels.set(label.htmlFor, friendlyName(label.textContent));
50    }
51
52    for (const control of [...form.elements]) {
53      if (!(control instanceof HTMLElement)) continue;
54      const type = (control.getAttribute("type") || "").toLowerCase();
55      if (type === "submit" || type === "button" || type === "image") continue;
56
57      const current = control.getAttribute("name") || "";
58      if (dropNames.has(current)) {
59        control.removeAttribute("name");
60        continue;
61      }
62
63      let nextName = control.id ? (labels.get(control.id) || "") : "";
64      if (!nextName) {
65        const wrap = control.closest(".wsite-form-field, .wsite-form-input-container, p, div, li, td");
66        const nearby = wrap ? wrap.querySelector("label") : null;
67        if (nearby) nextName = friendlyName(nearby.textContent);
68      }
69      if (!nextName && /_u\d+\[number\]/.test(current)) nextName = "Phone Number";
70      if (nextName) control.setAttribute("name", nextName);
71      else if (/^_u\d+/.test(current)) control.removeAttribute("name");
72    }
73
74    const email = form.querySelector('input[name="Email"]');
75    if (email && email.value) addHidden(form, "_replyto", email.value);
76
77    const next = new URL(window.location.href);
78    next.search = "?form_submitted=1";
79    next.hash = "";
80    addHidden(form, "_subject", "New Hyde Beauty & Wellness website inquiry");
81    addHidden(form, "_template", "table");
82    addHidden(form, "_next", next.href);
83    addHidden(form, "_url", window.location.href);
84    addHidden(form, "Page", window.location.pathname);
85
86    form.action = endpoint;
87    form.method = "POST";
88    form.setAttribute("enctype", "application/x-www-form-urlencoded");
89  }
90
91  function enhance() {
92    document.querySelectorAll('form[data-hyde-formsubmit="1"]').forEach(prepareForm);
93  }
94
95  window.addEventListener("submit", (event) => {
96    const form = event.target;
97    if (!(form instanceof HTMLFormElement) || form.dataset.hydeFormsubmit !== "1") return;
98    prepareForm(form);
99    event.stopImmediatePropagation();
100  }, true);
101
102  if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", enhance);
103  else enhance();
104
105  if (new URL(window.location.href).searchParams.get("form_submitted") === "1") {
106    const form = document.querySelector('form[data-hyde-formsubmit="1"]');
107    if (form) {
108      const notice = document.createElement("div");
109      notice.setAttribute("role", "status");
110      notice.style.cssText = "margin:0 0 16px;padding:14px;border:1px solid #4b6b50;background:#f2f8f3;color:#203b25;font-weight:600";
111      notice.textContent = "Thank you. Your message has been sent to Hyde Beauty & Wellness.";
112      form.parentNode.insertBefore(notice, form);
113    }
114  }
115})();

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.