PageSourceSearch

https://nagaragawahotel.com/common/assets/js/faq-json.js

js nagaragawahotel.com collected 2026-10-04 04:22:55 UTC 1,319 bytes, 55 lines download raw bytes

1
2// FAQページ構造化 JSON自動出力
3window.addEventListener("DOMContentLoaded", () => {
4  createFaqSchema();
5});
6
7function createFaqSchema() {
8  let faqSections = document.querySelectorAll(".acc");
9  if (!faqSections.length) {
10    return false;
11  }
12
13  const entities = [];
14  faqSections.forEach((section) => {
15    // 質問を取得
16    let question = section.querySelector(".faq__q").innerText.replace("Q", "").trim();
17    // その回答も取得
18    let answer = section.querySelector(".faq__a").innerText.replace("A", "").trim();
19    entities.push(createQuestionEntity(question, answer));
20  });
21
22  const schemaBody = {
23    "@context": "https://schema.org",
24    "@type": "FAQPage",
25    mainEntity: entities,
26  };
27
28  createSchemaElement(JSON.stringify(schemaBody));
29}
30
31// head内にJSON生成
32function createSchemaElement(structuredDataText) {
33  const script = document.createElement("script");
34  script.setAttribute("type", "application/ld+json");
35  script.textContent = structuredDataText;
36  document.head.appendChild(script);
37}
38
39function createQuestionEntity(question, answer) {
40  if (!question) {
41    return false;
42  }
43  if (!answer) {
44    return false;
45  }
46
47  return {
48    "@type": "Question",
49    name: `${question}`,
50    acceptedAnswer: {
51      "@type": "Answer",
52      text: `${answer}`,
53    },
54  };
55}

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.