27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
import subprocess, sys
|
|
|
|
jobs = {
|
|
"Subscriptions-CGNWQzow.js": ("N", "j", "u"),
|
|
"Users-CxW1h-sB.js": ("W", "H", "d"),
|
|
"Payments-BjNHIYXT.js": ("L", "F", "d"),
|
|
}
|
|
|
|
for fname, (arr, empty, fn) in jobs.items():
|
|
p = f"/tmp/admin-assets/{fname}"
|
|
src = open(p, encoding="utf-8").read()
|
|
cond = f"{arr}.value.length?"
|
|
assert src.count(cond) == 2, f"{fname}: cond count={src.count(cond)}"
|
|
# 1. open array before desktop branch (first occurrence; include paren
|
|
# so step 2 still uniquely matches the second condition)
|
|
s1 = src.replace(":" + cond + "(", ":" + cond + "[(", 1)
|
|
# 2. second condition -> comma (mobile branch becomes 2nd array element)
|
|
s2 = s1.replace(":" + cond + "(", ",(", 1)
|
|
# 3. close array before empty branch: `:(FN(),c(`div`,EMPTY,`
|
|
marker = f":({fn}(),c(`div`,{empty},"
|
|
assert s2.count(marker) == 1, f"{fname}: marker count={s2.count(marker)}"
|
|
s3 = s2.replace(marker, "]:" + "(" + fn + "(),c(`div`," + empty + ",", 1)
|
|
open(p, "w", encoding="utf-8").write(s3)
|
|
print(f"{fname}: patched ok, len {len(src)}->{len(s3)}")
|
|
|
|
print("ALL PATCHED")
|