# -*- coding: utf-8 -*- """Unlock remaining pages: strip global disabled={busy}, keep APIs identical.""" from __future__ import annotations import re from pathlib import Path ROOT = Path(r"c:\Users\admin\Desktop\douyinWEB") TARGETS = [ ROOT / "frontend/src/app/yt-long/page.tsx", ROOT / "frontend/src/app/x/ClipsPanel.tsx", ROOT / "desktop/src/pages/YoutubePage.tsx", ROOT / "frontend/src/app/youtube/page.tsx", ] def unlock(path: Path) -> None: t = path.read_text(encoding="utf-8") orig = t # Remove disabled={busy} and simplify disabled={busy || X} t = re.sub(r"\s*disabled=\{busy\}", "", t) t = t.replace("disabled={busy || ", "disabled={") t = t.replace("disabled={busy||", "disabled={") # Drop setBusy lock lines (API calls remain) t = t.replace(" setBusy(true);\n", "") t = t.replace(" setBusy(true);\n", "") t = t.replace(" setBusy(true);\n", "") t = re.sub( r"\n(\s*)\} finally \{\n\1 setBusy\(false\);\n\1\}", r"\n\1}", t, ) t = re.sub(r"\n(\s*)setBusy\(false\);\n", "\n", t) # Spinners referencing busy → always show icon (or false) t = t.replace("{busy ?