# -*- coding: utf-8 -*-
import io, sys, os, re, subprocess, tempfile
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
BASE = r"D:\work buddy\2026-11-05-14-15-52"
F = os.path.join(BASE, "index_main.html")
html = open(F, encoding="utf-8").read()
scripts = re.findall(r"<script>(.*?)</script>", html, re.S)
print("内嵌 script 块:", len(scripts))
for i, s in enumerate(scripts):
    if "const SCHOOLS" in s or "const CATD" in s:
        p = os.path.join(tempfile.gettempdir(), f"_uva_check_{i}.js")
        open(p, "w", encoding="utf-8", newline="").write(s)
        r = subprocess.run(["node", "--check", p], capture_output=True, text=True)
        print(f"块{i} node exit:", r.returncode)
        if r.stderr: print(r.stderr[:1500])
