PageSourceSearch

https://disniverse.com/assets/js/faq-schema.js

js disniverse.com collected 2026-10-09 05:20:35 UTC 1,281 bytes, 46 lines download raw bytes

1function faqQuestionText(summary) {
2  const clone = summary.cloneNode(true);
3  clone.querySelector('.faq__icon')?.remove();
4  return clone.textContent.replace(/\s+/g, ' ').trim();
5}
6
7function faqAnswerText(answer) {
8  return answer.textContent.replace(/\s+/g, ' ').trim();
9}
10
11/** Emit FAQPage JSON-LD from visible #faq markup (single source of truth). */
12export function initFaqSchema() {
13  const items = document.querySelectorAll('#faq .faq__item');
14  if (!items.length) return;
15
16  const mainEntity = Array.from(items, (item) => {
17    const summary = item.querySelector('.faq__question');
18    const answer = item.querySelector('.faq__answer p');
19    if (!summary || !answer) return null;
20
21    const name = faqQuestionText(summary);
22    const text = faqAnswerText(answer);
23    if (!name || !text) return null;
24
25    return {
26      '@type': 'Question',
27      name,
28      acceptedAnswer: {
29        '@type': 'Answer',
30        text,
31      },
32    };
33  }).filter(Boolean);
34
35  if (!mainEntity.length) return;
36
37  const script = document.createElement('script');
38  script.type = 'application/ld+json';
39  script.textContent = JSON.stringify({
40    '@context': 'https://schema.org',
41    '@type': 'FAQPage',
42    mainEntity,
43  }).replace(/</g, '\\u003c');
44
45  document.head.appendChild(script);
46}

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.