-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
672 lines (612 loc) · 28 KB
/
Copy pathapp.js
File metadata and controls
672 lines (612 loc) · 28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
(function () {
"use strict";
const ANALYTICS_KEY = "jsrenderqa_analytics_events";
const INTENT_KEY = "jsrenderqa_purchase_intents";
const GITHUB_ISSUE_URL = "https://github.com/ert93333-ops/javascript-rendering-qa-briefs/issues/new";
const SAMPLE_INITIAL_HTML = [
"<html>",
" <head>",
" <title></title>",
" <meta name=\"description\" content=\"\">",
" </head>",
" <body>",
" <div id=\"app\"></div>",
" <script src=\"/static/chunks/app.js\"></script>",
" <a onclick=\"go('/products')\">Products</a>",
" <a href=\"#features\">Features</a>",
" </body>",
"</html>",
].join("\n");
const SAMPLE_RENDERED_HTML = [
"<html>",
" <head>",
" <title>Acme Store</title>",
" <meta name=\"description\" content=\"Shop Acme products and replacement parts.\">",
" </head>",
" <body>",
" <main>",
" <h1>Acme Store</h1>",
" <p>Buy durable widgets and replacement parts before the migration launch.</p>",
" <a href=\"/products\">Products</a>",
" <button onclick=\"loadReviews()\">Load reviews</button>",
" <img data-src=\"/hero.jpg\" alt=\"Acme widget hero\">",
" </main>",
" </body>",
"</html>",
].join("\n");
const SAMPLE_CRITICAL_NOTES = [
"Critical product copy and H1 only appear after hydration.",
"Reviews load after button click.",
"Hero image uses data-src until IntersectionObserver fires.",
"No team has written the launch plan yet.",
].join("\n");
const SAMPLE_LINK_SNIPPETS = [
"<a onclick=\"go('/products')\">Products</a>",
"<a href=\"#features\">Features</a>",
"<button onclick=\"loadMore()\">Load more products</button>",
"<a href=\"/docs\">Docs</a>",
].join("\n");
const SAMPLE_ROUTE_NOTES = [
"Routes use #/products on staging.",
"Category pages are generated client-side after hydration.",
"Some product tabs use fragments instead of crawlable URLs.",
].join("\n");
const SAMPLE_RESOURCE_NOTES = [
"robots.txt blocks /assets/app.js and /static/chunks/.",
"CSS and JS are behind an auth-like CDN rule for unknown user agents.",
"Reviews and recommendations load after click/scroll.",
].join("\n");
const FALLBACK_PATTERN = /ssr|server[- ]render|pre[- ]render|static html|fallback|noscript|crawlable href|plain href|unblock|allow js|allow css|owner|fix|remediation|decision/i;
const LAZY_PATTERN = /lazy|data-src|intersectionobserver|scroll|click|button|accordion|tab|load more|user action|after interaction|on demand|defer/i;
const BLOCKED_PATTERN = /blocked|disallow|robots\.txt|cdn|waf|403|401|auth|unknown user[- ]agent|static\/chunks|assets\/|app\.js|style\.css|css|javascript|js/i;
const HASH_ROUTE_PATTERN = /#\/|hash route|hash-route|fragment route|fragment|href=["']#|route.*#/i;
const state = {
latestBrief: null,
latestBriefText: "",
lastRemoteBody: "",
signupStarted: false,
pricingTracked: false,
};
function qs(selector, root) {
return (root || document).querySelector(selector);
}
function qsa(selector, root) {
return Array.from((root || document).querySelectorAll(selector));
}
function setText(selector, value) {
const element = qs(selector);
if (element) element.textContent = value;
}
function clean(value) {
return String(value || "").replace(/\s+/g, " ").trim();
}
function readArray(key) {
try {
const raw = window.localStorage.getItem(key);
return raw ? JSON.parse(raw) : [];
} catch (error) {
return [];
}
}
function writeArray(key, value) {
try {
window.localStorage.setItem(key, JSON.stringify(value));
} catch (error) {
// Local storage can be unavailable in privacy modes. The workflow still works.
}
}
function getUtm() {
const params = new URLSearchParams(window.location.search);
return {
utm_source: params.get("utm_source") || "",
utm_medium: params.get("utm_medium") || "",
utm_campaign: params.get("utm_campaign") || "",
utm_content: params.get("utm_content") || "",
};
}
function track(eventName, detail) {
const events = readArray(ANALYTICS_KEY);
events.push({
event: eventName,
detail: detail || {},
utm: getUtm(),
path: window.location.pathname,
createdAt: new Date().toISOString(),
});
writeArray(ANALYTICS_KEY, events.slice(-200));
}
function escapeHtml(value) {
return String(value)
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
}
function listHtml(items, emptyText) {
if (!items.length) return "<p>" + escapeHtml(emptyText) + "</p>";
return "<ul>" + items.map(function (item) {
return "<li>" + escapeHtml(item) + "</li>";
}).join("") + "</ul>";
}
function unique(items) {
return Array.from(new Set(items.map(clean).filter(Boolean)));
}
function parseHtml(raw) {
try {
return new DOMParser().parseFromString(String(raw || ""), "text/html");
} catch (error) {
return document.implementation.createHTMLDocument("parse-error");
}
}
function readableBodyText(doc) {
const clone = doc.body ? doc.body.cloneNode(true) : null;
if (!clone) return "";
Array.from(clone.querySelectorAll("script, style, noscript, template")).forEach(function (node) {
node.remove();
});
return clean(clone.textContent || "");
}
function titleText(doc) {
return clean((doc.querySelector("title") || {}).textContent || "");
}
function metaDescription(doc) {
const meta = doc.querySelector('meta[name="description" i]');
return clean(meta ? meta.getAttribute("content") : "");
}
function anchorFindings(rawSnippets, initialDoc, renderedDoc) {
const doc = parseHtml("<body>" + rawSnippets + "</body>");
const anchors = qsa("a", doc).concat(qsa("a", initialDoc), qsa("a", renderedDoc));
const buttons = qsa("button", doc).concat(qsa("button", initialDoc), qsa("button", renderedDoc));
const linkWarnings = [];
const routeWarnings = [];
anchors.forEach(function (anchor) {
const label = clean(anchor.textContent || anchor.getAttribute("aria-label") || "anchor");
const href = clean(anchor.getAttribute("href") || "");
const onclick = clean(anchor.getAttribute("onclick") || "");
if (!href || onclick || /^javascript:/i.test(href)) {
linkWarnings.push("JS-only or missing crawlable link: " + label + " needs a real href for crawler-visible navigation.");
}
if (href === "#" || href.charAt(0) === "#" || href.indexOf("#/") !== -1) {
routeWarnings.push("hash-route or fragment route risk: " + label + " uses " + (href || "a fragment-only link") + " instead of a crawlable route.");
}
});
buttons.forEach(function (button) {
const label = clean(button.textContent || button.getAttribute("aria-label") || "button");
if (/product|docs|route|more|load|next|category|review/i.test(label + " " + (button.getAttribute("onclick") || ""))) {
linkWarnings.push("JS-only or missing crawlable link: " + label + " is exposed as a button/user action instead of a crawlable href.");
}
});
return {
linkWarnings: unique(linkWarnings),
routeWarnings: unique(routeWarnings),
};
}
function analyzeRendering(input) {
const initialDoc = parseHtml(input.initialHtml);
const renderedDoc = parseHtml(input.renderedHtml);
const initialText = readableBodyText(initialDoc);
const renderedText = readableBodyText(renderedDoc);
const initialTitle = titleText(initialDoc);
const initialDescription = metaDescription(initialDoc);
const renderedTitle = titleText(renderedDoc);
const renderedDescription = metaDescription(renderedDoc);
const combinedNotes = [
input.criticalNotes,
input.linkSnippets,
input.routeNotes,
input.resourceNotes,
input.initialHtml,
input.renderedHtml,
].join("\n");
const parseSummary = [
"Template type: " + clean(input.templateType),
"Initial body text length: " + initialText.length + " characters.",
"Rendered body text length: " + renderedText.length + " characters.",
"Initial title: " + (initialTitle || "missing"),
"Rendered title: " + (renderedTitle || "missing"),
"Initial meta description: " + (initialDescription || "missing"),
"Rendered meta description: " + (renderedDescription || "missing"),
];
const initialWarnings = [];
const renderedOnlyWarnings = [];
const crawlableLinkWarnings = [];
const routeWarnings = [];
const lazyWarnings = [];
const blockedWarnings = [];
const fallbackWarnings = [];
const handoffReminders = [
"Retest after SSR, pre-rendering, routing, link markup, lazy-loading, CDN, robots, or fallback changes ship.",
"Treat this as JavaScript rendering SEO launch QA guidance; it does not fetch pages, crawl a site, emulate Googlebot, replace Search Console, or guarantee crawling, indexing, rankings, rendering, or Search Console outcomes.",
];
const rootShells = qsa("#app, #root, #__next, [data-reactroot]", initialDoc).filter(function (node) {
return clean(node.textContent).length < 12;
});
if ((initialText.length < 100 && renderedText.length > initialText.length + 50) || (rootShells.length && renderedText.length > initialText.length + 50)) {
initialWarnings.push("empty app shell: initial HTML has little crawlable body text while rendered HTML contains meaningful page content.");
}
if (!initialTitle) {
initialWarnings.push("missing initial title: source HTML title is empty or absent before JavaScript runs.");
}
if (!initialDescription) {
initialWarnings.push("missing initial meta description: source HTML meta description is empty or absent before JavaScript runs.");
}
const renderedH1 = clean((renderedDoc.querySelector("h1") || {}).textContent || "");
const initialH1 = clean((initialDoc.querySelector("h1") || {}).textContent || "");
if ((renderedH1 && renderedH1 !== initialH1) || renderedText.length > Math.max(180, initialText.length * 2) || /only appear after hydration|rendered only|after javascript|client-side/i.test(input.criticalNotes)) {
renderedOnlyWarnings.push("critical content only present in rendered HTML: important headings, copy, or links appear after JavaScript/hydration instead of in initial HTML.");
}
if (renderedTitle && renderedTitle !== initialTitle) {
renderedOnlyWarnings.push("critical content only present in rendered HTML: page title is corrected only after rendering.");
}
if (renderedDescription && renderedDescription !== initialDescription) {
renderedOnlyWarnings.push("critical content only present in rendered HTML: meta description is corrected only after rendering.");
}
const linkResult = anchorFindings(input.linkSnippets, initialDoc, renderedDoc);
crawlableLinkWarnings.push.apply(crawlableLinkWarnings, linkResult.linkWarnings);
routeWarnings.push.apply(routeWarnings, linkResult.routeWarnings);
if (HASH_ROUTE_PATTERN.test(input.routeNotes + "\n" + input.linkSnippets)) {
routeWarnings.push("hash-route or fragment route risk: route notes or snippets mention hash routes/fragments that may not create distinct crawlable URLs.");
}
if (LAZY_PATTERN.test(combinedNotes)) {
lazyWarnings.push("lazy/user-action content risk: critical content, reviews, links, or media depend on click, scroll, IntersectionObserver, data-src, load more, or another user action.");
}
if (BLOCKED_PATTERN.test(input.resourceNotes)) {
blockedWarnings.push("blocked JS/CSS/resource: notes mention robots.txt, CDN, auth, 403/401, WAF, chunks, assets, app.js, CSS, or JS resources that may prevent rendering.");
}
if (!FALLBACK_PATTERN.test(input.criticalNotes + "\n" + input.routeNotes + "\n" + input.resourceNotes)) {
fallbackWarnings.push("missing fallback or owner remediation decision: notes do not name SSR, pre-render, static fallback, crawlable href, unblock, or an owner decision.");
}
if (initialWarnings.length + renderedOnlyWarnings.length + crawlableLinkWarnings.length + routeWarnings.length + lazyWarnings.length + blockedWarnings.length > 0 && !/owner|remediation|decision|fix|ticket|assigned/i.test(input.criticalNotes + "\n" + input.routeNotes + "\n" + input.resourceNotes)) {
fallbackWarnings.push("missing fallback or owner remediation decision: assign a frontend, SEO, platform, or content owner before launch signoff.");
}
const issueCount =
initialWarnings.length +
renderedOnlyWarnings.length +
crawlableLinkWarnings.length +
routeWarnings.length +
lazyWarnings.length +
blockedWarnings.length +
fallbackWarnings.length;
const status = initialWarnings.length || renderedOnlyWarnings.length || crawlableLinkWarnings.length || blockedWarnings.length
? "Fix before launch"
: routeWarnings.length || lazyWarnings.length || fallbackWarnings.length
? "Manual review"
: "Ready for final JavaScript SEO QA";
return {
status: status,
issueCount: issueCount,
templateType: clean(input.templateType),
parseSummary: unique(parseSummary),
initialWarnings: unique(initialWarnings),
renderedOnlyWarnings: unique(renderedOnlyWarnings),
crawlableLinkWarnings: unique(crawlableLinkWarnings),
routeWarnings: unique(routeWarnings),
lazyWarnings: unique(lazyWarnings),
blockedWarnings: unique(blockedWarnings),
fallbackWarnings: unique(fallbackWarnings),
handoffReminders: unique(handoffReminders),
};
}
function briefToText(brief) {
return [
"JavaScript Rendering QA Briefs",
"Status: " + brief.status,
"Issue count: " + brief.issueCount,
"Template type: " + brief.templateType,
"",
"Parse summary:",
brief.parseSummary.length ? brief.parseSummary.join("\n") : "None found.",
"",
"Initial HTML warnings:",
brief.initialWarnings.length ? brief.initialWarnings.join("\n") : "None found.",
"",
"Rendered-only content warnings:",
brief.renderedOnlyWarnings.length ? brief.renderedOnlyWarnings.join("\n") : "None found.",
"",
"Crawlable link warnings:",
brief.crawlableLinkWarnings.length ? brief.crawlableLinkWarnings.join("\n") : "None found.",
"",
"Route and fragment warnings:",
brief.routeWarnings.length ? brief.routeWarnings.join("\n") : "None found.",
"",
"Lazy/user-action content warnings:",
brief.lazyWarnings.length ? brief.lazyWarnings.join("\n") : "None found.",
"",
"Blocked resource warnings:",
brief.blockedWarnings.length ? brief.blockedWarnings.join("\n") : "None found.",
"",
"Fallback and owner decision reminders:",
brief.fallbackWarnings.length ? brief.fallbackWarnings.join("\n") : "None found.",
"",
"Handoff reminders:",
brief.handoffReminders.join("\n"),
"",
"Note: This is JavaScript rendering SEO launch QA guidance, not a crawler, Search Console replacement, Googlebot emulator, or guarantee of crawling, rendering, indexing, rankings, or Search Console outcomes.",
].join("\n");
}
function renderBrief(brief) {
const output = qs("#brief-output");
const copyButton = qs("#copy-brief");
const outputPanel = qs(".output-panel");
const statusPill = qs("#status-pill");
if (!output) return;
output.classList.remove("empty");
output.classList.add("is-updated");
window.setTimeout(function () { output.classList.remove("is-updated"); }, 480);
output.innerHTML = [
'<div class="brief-summary">',
'<strong>' + escapeHtml(brief.status) + '</strong>',
'<span>' + brief.issueCount + ' checks need attention</span>',
"</div>",
'<section class="brief-section"><h4>Parse summary</h4>' + listHtml(brief.parseSummary, "No parse notes found.") + "</section>",
'<section class="brief-section"><h4>Initial HTML warnings</h4>' + listHtml(brief.initialWarnings, "No initial HTML warnings found.") + "</section>",
'<section class="brief-section"><h4>Rendered-only content warnings</h4>' + listHtml(brief.renderedOnlyWarnings, "No rendered-only content warnings found.") + "</section>",
'<section class="brief-section"><h4>Crawlable link warnings</h4>' + listHtml(brief.crawlableLinkWarnings, "No crawlable link warnings found.") + "</section>",
'<section class="brief-section"><h4>Route and fragment warnings</h4>' + listHtml(brief.routeWarnings, "No route or fragment warnings found.") + "</section>",
'<section class="brief-section"><h4>Lazy/user-action content warnings</h4>' + listHtml(brief.lazyWarnings, "No lazy or user-action warnings found.") + "</section>",
'<section class="brief-section"><h4>Blocked resource warnings</h4>' + listHtml(brief.blockedWarnings, "No blocked resource warnings found.") + "</section>",
'<section class="brief-section"><h4>Fallback and owner decision reminders</h4>' + listHtml(brief.fallbackWarnings, "No fallback or owner decision reminders found.") + "</section>",
'<section class="brief-section"><h4>Handoff reminders</h4>' + listHtml(brief.handoffReminders, "No handoff reminders found.") + "</section>",
].join("");
setText("#output-title", "JavaScript rendering QA brief ready");
setText("#status-pill", brief.status);
if (copyButton) copyButton.disabled = false;
if (outputPanel) {
outputPanel.classList.add("has-brief");
outputPanel.classList.toggle("status-good", brief.status === "Ready for final JavaScript SEO QA");
outputPanel.classList.toggle("status-warning", brief.status === "Manual review");
outputPanel.classList.toggle("status-danger", brief.status === "Fix before launch");
}
if (statusPill) {
statusPill.classList.toggle("status-good", brief.status === "Ready for final JavaScript SEO QA");
statusPill.classList.toggle("status-warning", brief.status === "Manual review");
statusPill.classList.toggle("status-danger", brief.status === "Fix before launch");
}
state.latestBrief = brief;
state.latestBriefText = briefToText(brief);
}
function pulseClass(element, className, duration) {
if (!element) return;
element.classList.add(className);
window.setTimeout(function () { element.classList.remove(className); }, duration || 600);
}
async function copyText(text) {
if (navigator.clipboard && navigator.clipboard.writeText) {
try {
await navigator.clipboard.writeText(text);
return;
} catch (error) {
// Fall through to textarea fallback for headless browser clipboard blocks.
}
}
const textarea = document.createElement("textarea");
textarea.value = text;
textarea.setAttribute("readonly", "");
textarea.style.position = "fixed";
textarea.style.opacity = "0";
document.body.appendChild(textarea);
textarea.select();
document.execCommand("copy");
textarea.remove();
}
function setupAuditor() {
const form = qs("#auditor-form");
const initialHtml = qs("#initial-html");
const renderedHtml = qs("#rendered-html");
const criticalNotes = qs("#critical-notes");
const linkSnippets = qs("#link-snippets");
const routeNotes = qs("#route-notes");
const resourceNotes = qs("#resource-notes");
const loadSample = qs("#load-sample");
const error = qs("#workflow-error");
const copyButton = qs("#copy-brief");
if (!form || !initialHtml || !renderedHtml) return;
if (loadSample) {
loadSample.addEventListener("click", function () {
initialHtml.value = SAMPLE_INITIAL_HTML;
renderedHtml.value = SAMPLE_RENDERED_HTML;
if (criticalNotes) criticalNotes.value = SAMPLE_CRITICAL_NOTES;
if (linkSnippets) linkSnippets.value = SAMPLE_LINK_SNIPPETS;
if (routeNotes) routeNotes.value = SAMPLE_ROUTE_NOTES;
if (resourceNotes) resourceNotes.value = SAMPLE_RESOURCE_NOTES;
if (qs("#template-type")) qs("#template-type").value = "SPA product page";
initialHtml.focus();
pulseClass(loadSample, "is-confirmed", 520);
track("sample_js_render_rows_loaded");
});
}
form.addEventListener("submit", function (event) {
event.preventDefault();
track("core_action_started", { triggerSource: "auditor_form" });
if (error) error.textContent = "";
const input = {
initialHtml: initialHtml.value.trim(),
renderedHtml: renderedHtml.value.trim(),
criticalNotes: criticalNotes ? criticalNotes.value.trim() : "",
linkSnippets: linkSnippets ? linkSnippets.value.trim() : "",
routeNotes: routeNotes ? routeNotes.value.trim() : "",
resourceNotes: resourceNotes ? resourceNotes.value.trim() : "",
templateType: qs("#template-type") ? qs("#template-type").value : "",
};
const inputLength = Object.keys(input).reduce(function (total, key) { return total + String(input[key]).length; }, 0);
if (!input.initialHtml || !input.renderedHtml) {
if (error) error.textContent = "Paste initial HTML and rendered HTML samples or load the sample before generating a JavaScript rendering QA brief.";
track("core_action_failed", { reason: "empty_input" });
return;
}
const brief = analyzeRendering(input);
renderBrief(brief);
track("core_action_completed", {
issueCount: brief.issueCount,
status: brief.status,
templateType: brief.templateType,
inputLength: inputLength,
});
});
if (copyButton) {
copyButton.addEventListener("click", function () {
if (!state.latestBriefText) return;
copyText(state.latestBriefText).then(function () {
copyButton.textContent = "Copied brief";
pulseClass(copyButton, "is-confirmed", 700);
track("brief_copied", { issueCount: state.latestBrief ? state.latestBrief.issueCount : 0 });
window.setTimeout(function () { copyButton.textContent = "Copy brief"; }, 1400);
});
});
}
}
function buildRemoteIssue(intent) {
const body = [
"JavaScript Rendering QA Briefs early-access request",
"",
"Role: " + intent.role,
"Site type: " + intent.siteType,
"JS templates: " + intent.templateCount,
"Plan interest: " + intent.plan,
"Willingness to pay: " + intent.budget,
"Purchase intent: " + (intent.purchaseIntent ? "yes" : "no"),
"",
"Biggest JavaScript SEO QA pain:",
intent.pain,
"",
"Note: Email is intentionally omitted from this public issue body.",
].join("\n");
state.lastRemoteBody = body;
const params = new URLSearchParams({
title: "JavaScript Rendering QA Briefs early-access request",
body: body,
labels: "early-access,purchase-intent,demo-request",
template: "demo_request.md",
});
return GITHUB_ISSUE_URL + "?" + params.toString();
}
function setupWaitlist() {
const form = qs("#waitlist-form");
const status = qs("#waitlist-status");
const handoff = qs("#handoff-panel");
const remoteLink = qs("#remote-intent-link");
const copyRequest = qs("#copy-request");
const planSelect = qs("#plan");
if (!form) return;
form.addEventListener("focusin", function () {
if (!state.signupStarted) {
state.signupStarted = true;
track("signup_started", { triggerSource: "waitlist_form" });
}
});
form.addEventListener("submit", function (event) {
event.preventDefault();
if (!state.signupStarted) {
state.signupStarted = true;
track("signup_started", { triggerSource: "waitlist_submit" });
}
const intent = {
email: qs("#email") ? qs("#email").value.trim() : "",
role: qs("#role") ? qs("#role").value : "",
siteType: qs("#site-type-intent") ? qs("#site-type-intent").value : "",
templateCount: qs("#template-count") ? qs("#template-count").value : "",
plan: planSelect ? planSelect.value : "",
budget: qs("#budget") ? qs("#budget").value : "",
pain: qs("#pain") ? qs("#pain").value.trim() : "",
purchaseIntent: qs("#purchase-intent") ? qs("#purchase-intent").checked : false,
createdAt: new Date().toISOString(),
utm: getUtm(),
};
const intents = readArray(INTENT_KEY);
intents.push(intent);
writeArray(INTENT_KEY, intents.slice(-100));
const remoteHref = buildRemoteIssue(intent);
if (remoteLink) remoteLink.href = remoteHref;
if (handoff) {
handoff.hidden = false;
pulseClass(handoff, "is-confirmed", 700);
}
if (status) status.textContent = "You are on the early access list. Public-safe request details are ready.";
track("waitlist_submitted", { role: intent.role, plan: intent.plan, templateCount: intent.templateCount });
track("feedback_submitted", { triggerSource: "waitlist_form", painLength: intent.pain.length });
track("remote_intent_ready", { hasRemoteLink: Boolean(remoteHref) });
if (intent.purchaseIntent) track("checkout_intent", { plan: intent.plan, budget: intent.budget });
});
if (copyRequest) {
copyRequest.addEventListener("click", function () {
if (!state.lastRemoteBody) return;
copyText(state.lastRemoteBody).then(function () {
copyRequest.textContent = "Copied request details";
pulseClass(copyRequest, "is-confirmed", 700);
track("remote_intent_copied", { bodyLength: state.lastRemoteBody.length });
window.setTimeout(function () { copyRequest.textContent = "Copy request details"; }, 1500);
});
});
}
}
function setupPlanButtons() {
const waitlist = qs("#waitlist");
const planSelect = qs("#plan");
qsa(".plan-button").forEach(function (button) {
button.addEventListener("click", function () {
const plan = button.getAttribute("data-plan") || "";
if (planSelect && plan) planSelect.value = plan;
track("pricing_viewed", { triggerSource: "plan_button" });
state.pricingTracked = true;
track("checkout_started", { plan: plan, triggerSource: "pricing_button" });
pulseClass(button, "is-confirmed", 500);
if (waitlist) waitlist.scrollIntoView({ behavior: "smooth", block: "start" });
});
});
}
function setupTracking() {
track("landing_viewed", { product: "JavaScript Rendering QA Briefs" });
qsa("[data-track-cta]").forEach(function (element) {
element.addEventListener("click", function () {
track("cta_clicked", { cta: element.getAttribute("data-track-cta") || element.textContent.trim() });
});
});
const pricing = qs("#pricing");
if (pricing && "IntersectionObserver" in window) {
const observer = new IntersectionObserver(function (entries) {
entries.forEach(function (entry) {
if (entry.isIntersecting && !state.pricingTracked) {
state.pricingTracked = true;
track("pricing_viewed", { triggerSource: "scroll" });
observer.disconnect();
}
});
}, { threshold: 0.35 });
observer.observe(pricing);
}
}
function setupChrome() {
const header = qs("[data-header]");
if (!header) return;
function updateHeader() {
header.classList.toggle("is-scrolled", window.scrollY > 8);
}
updateHeader();
window.addEventListener("scroll", updateHeader, { passive: true });
}
function setupReveal() {
const elements = qsa(".reveal");
if (!("IntersectionObserver" in window)) {
elements.forEach(function (element) { element.classList.add("is-visible"); });
return;
}
const observer = new IntersectionObserver(function (entries) {
entries.forEach(function (entry) {
if (entry.isIntersecting) {
entry.target.classList.add("is-visible");
observer.unobserve(entry.target);
}
});
}, { threshold: 0.12 });
elements.forEach(function (element) { observer.observe(element); });
}
document.addEventListener("DOMContentLoaded", function () {
setupTracking();
setupChrome();
setupReveal();
setupAuditor();
setupWaitlist();
setupPlanButtons();
});
}());