57 lines
1.6 KiB
Python
57 lines
1.6 KiB
Python
# -*- 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 ? <Loader2", "{false ? <Loader2")
|
|
if t == orig:
|
|
print("no change", path.name)
|
|
else:
|
|
path.write_text(t, encoding="utf-8")
|
|
print(
|
|
"ok",
|
|
path.relative_to(ROOT),
|
|
"disabled_busy",
|
|
t.count("disabled={busy}"),
|
|
"setBusy",
|
|
t.count("setBusy"),
|
|
)
|
|
|
|
|
|
for p in TARGETS:
|
|
if not p.is_file():
|
|
print("missing", p)
|
|
continue
|
|
unlock(p)
|
|
print("DONE")
|