@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.1.150",
3
+ "version": "1.1.152",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -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
- idx = html.lower().rfind("</body>")
453
- if idx != -1:
454
- html = html[:idx] + tag + "\n" + html[idx:]
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")