# LLMO SEO — VALIDATION SCRIPTS (PowerShell & Linux)
# Test domain used below:
https://forum.example.com/threads/123/
# Copy the two scripts into files as named, make them executable (Linux),
# then run with your forum URL or rely on the default test URL.
==================================================
# FILE: Validate-Llmo.ps1 (PowerShell, Windows/macOS/Linux)
# USAGE NOTE:
# 1) Save as: Validate-Llmo.ps1
# 2) Run:
# pwsh ./Validate-Llmo.ps1 -Url "
https://yourforum.tld/threads/123/"
# or (Windows PowerShell):
# powershell -ExecutionPolicy Bypass -File .\Validate-Llmo.ps1 -Url "
https://yourforum.tld/threads/123/"
# 3) Default (no param) uses the test domain:
https://forum.example.com/threads/123/
# What it does:
# - Fetches the page, extracts <script id="llmo-seo">…</script>,
# - HTML-decodes its content, parses JSON, checks @context/@type and size ≤ 50 KB.
# Exit codes: 0 = valid, 1 = invalid/error.
param(
[Parameter(Position=0)]
[string]$Url = "
https://forum.example.com/threads/123/"
)
try {
$resp = Invoke-WebRequest -Uri $Url -TimeoutSec 15
} catch {
Write-Error "HTTP request failed: $($_.Exception.Message)"; exit 1
}
$html = $resp.Content
$regex = '<script[^>]+id=["'']llmo-seo["''][^>]
>(.?)</script>'
$opts = [System.Text.RegularExpressions.RegexOptions]::Singleline -bor `
[System.Text.RegularExpressions.RegexOptions]::IgnoreCase
$m = [regex]::Match($html, $regex, $opts)
if (-not $m.Success) { Write-Host "ERROR: No LLMO JSON-LD found."; exit 1 }
$raw = [System.Net.WebUtility]::HtmlDecode($m.Groups[1].Value)
try {
$json = $raw | ConvertFrom-Json -Depth 64
} catch {
Write-Host "ERROR: Invalid JSON: $($_.Exception.Message)"; exit 1
}
$bytes = [System.Text.Encoding]::UTF8.GetBytes($raw)
if ($bytes.Length -gt 51200) {
Write-Host "ERROR: JSON-LD exceeds 50KB."; exit 1
}
$hasContext = $json.PSObject.Properties.Name -contains "@context"
$hasType = $json.PSObject.Properties.Name -contains "@type"
if (-not ($hasContext -and $hasType)) {
Write-Host "ERROR: Missing @context or @type."; exit 1
}
$type = $json.'@type'
Write-Host ("OK: LLMO JSON-LD valid. Size={0} bytes; type={1}" -f $bytes.Length, $type)
exit 0
==================================================
# FILE: validate-llmo.sh (Linux/macOS with bash + Python 3)
# USAGE NOTE:
# 1) Save as: validate-llmo.sh
# 2) Make executable: chmod +x validate-llmo.sh
# 3) Run:
# ./validate-llmo.sh "
https://yourforum.tld/threads/123/"
# Or rely on default (test domain) if no URL is passed:
# ./validate-llmo.sh
# Requirements: bash + python3 (standard library only; no extra packages).
# What it does:
# - Fetches the page, extracts <script id="llmo-seo">…</script>,
# - HTML-decodes its content, parses JSON, checks @context/@type and size ≤ 50 KB.
# Exit codes: 0 = valid, 1 = invalid/error.
#!/usr/bin/env bash
set -euo pipefail
URL="${1:-https://forum.example.com/threads/123/}"
python3 - "$URL" <<'PYCODE'
import sys, re, html, json, urllib.request
def main(url: str) -> int:
try:
with urllib.request.urlopen(url, timeout=15) as r:
html_text = r.read().decode('utf-8', 'replace')
except Exception as e:
print(f"ERROR: HTTP request failed: {e}", file=sys.stderr)
return 1
m = re.search(r'<script[^>]+id=["\']llmo-seo["\'][^>]
>(.?)</script>', html_text, re.I | re.S)
if not m:
print("ERROR: No LLMO JSON-LD found.", file=sys.stderr)
return 1
raw = html.unescape(m.group(1))
try:
data = json.loads(raw)
except Exception as e:
print(f"ERROR: Invalid JSON: {e}", file=sys.stderr)
return 1
size = len(raw.encode('utf-8'))
if size > 50 * 1024:
print("ERROR: JSON-LD exceeds 50KB.", file=sys.stderr)
return 1
if "@context" not in data or "@type" not in data:
print("ERROR: Missing @context or @type.", file=sys.stderr)
return 1
print(f"OK: LLMO JSON-LD valid. Size={size} bytes; type={data.get('@type')}")
return 0
if
name == "
main":
sys.exit(main(sys.argv[1]))
PYCODE