Files
weval-l99/patch_wtp_v70_bytes.py
2026-04-20 04:10:40 +02:00

39 lines
1.8 KiB
Python

#!/usr/bin/env python3
path = "/var/www/html/weval-technology-platform.html"
with open(path, "rb") as f:
raw = f.read()
if b"crm_bridge" in raw:
print("ALREADY_PATCHED")
exit(0)
# Exact bytes: 'truth', icon:'🔒' (\xf0\x9f\x94\x92), label:'Truth Registry', color:'#22c55e', count: TREE.truth_registry?.agents||0},
# In HTML context single quotes are literal (no backslash escape because we're in innerText template literal? let me check)
# From dbg: b"'truth\\', icon:\\'\\xf0..." - YES backslash-escaped single quotes
target_truth_line = b"'truth\\', icon:\\'\xf0\x9f\x94\x92\\', label:\\'Truth Registry\\', color:\\'#22c55e\\', count: TREE.truth_registry?.agents||0},"
if target_truth_line in raw:
# Add crm_bridge as 6th extras entry just after truth, before closing ];
new_entry = b"\n {id:\\'crm_bridge\\', icon:\\'\xf0\x9f\x94\x97\\', label:\\'CRM Bridge (4 CRMs)\\', color:\\'#22d3ee\\', count: 4},"
new_raw = raw.replace(target_truth_line, target_truth_line + new_entry, 1)
# Also patch navigateTo dispatcher
nav_old = b"else if (modId === 'all_pages') renderAllPages();"
nav_new = b"else if (modId === 'crm_bridge') { window.open('/wevia-ia/wevia-admin-crm-v68.php', '_blank'); return; }\n else if (modId === 'all_pages') renderAllPages();"
if nav_old in new_raw:
new_raw = new_raw.replace(nav_old, nav_new, 1)
with open(path, "wb") as f:
f.write(new_raw)
added = len(new_raw) - len(raw)
print(f"PATCHED ok - {len(raw)}{len(new_raw)} (+{added}B)")
print(f"crm_bridge count: {new_raw.count(b'crm_bridge')}")
else:
print("TARGET_NOT_FOUND - investigating...")
idx = raw.find(b"truth_registry")
print(f"truth_registry at {idx}")
print(f"ctx: {raw[idx-60:idx+120]!r}")