@aiyiran/myclaw 1.1.150 → 1.1.152
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server/sync_workspace.py +9 -3
package/package.json
CHANGED
package/server/sync_workspace.py
CHANGED
|
@@ -449,9 +449,15 @@ def inject_probe_into_html(html_bytes):
|
|
|
449
449
|
)
|
|
450
450
|
|
|
451
451
|
tag = f'<script {PROBE_MARKER_ATTR}="{version}">\n{src}\n</script>'
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
452
|
+
# 注入到 <body> 开头而非 </body> 前,确保 probe 在游戏脚本之前加载,
|
|
453
|
+
# 能捕获 init() 等同步执行阶段的报错。
|
|
454
|
+
body_open = html.lower().find("<body")
|
|
455
|
+
if body_open != -1:
|
|
456
|
+
body_tag_end = html.find(">", body_open)
|
|
457
|
+
if body_tag_end != -1:
|
|
458
|
+
html = html[:body_tag_end + 1] + "\n" + tag + html[body_tag_end + 1:]
|
|
459
|
+
else:
|
|
460
|
+
html = html + "\n" + tag
|
|
455
461
|
else:
|
|
456
462
|
html = html + "\n" + tag
|
|
457
463
|
return html.encode("utf-8")
|