import frida, time, subprocess, sys
sys.path.insert(0,"/root/ants"); import emu
JS=r"""
function ins(){var m=Process.findModuleByName("libil2cpp.so");if(!m)return false;var b=m.base;
 try{ // NOP 'mov byte[eax+0x3e],6' @5f2325 (4 bytes) and 'call ecx' @5f23a8 (2 bytes)
   var p1=b.add(0x5f2325);Memory.protect(p1,8,'rwx');p1.writeByteArray([0x90,0x90,0x90,0x90]);
   var p2=b.add(0x5f23a8);Memory.protect(p2,4,'rwx');p2.writeByteArray([0x90,0x90]);
   send({g:"[timeout-disconnect NOPed]"});}catch(e){send({g:"patch err "+e});}
 function H(a,nm){try{Interceptor.attach(b.add(a),{onEnter:function(){send({g:nm});}});}catch(e){}}
 H(0x100522a,"OnJoinedRoom");H(0x1004646,"OnDisconnected");
 H(0xe484bd,"GameController.Start");H(0xe4bd6a,"SpawnPlayers");H(0x1003614,"LoadSingleLevel");
 send({g:"__ready"});return true;}
if(!ins()){var iv=setInterval(function(){if(ins())clearInterval(iv);},100);}
"""
t=emu.launch_to_menu(); print(f"menu {t:.0f}s",flush=True)
dev=frida.get_usb_device(timeout=10)
pid=int(subprocess.run([emu.ADB,"shell","pidof","se.foglo.svt"],capture_output=True,text=True).stdout.split()[0])
s=dev.attach(pid); sc=s.create_script(JS)
sc.on("message",lambda m,d: print(m.get("payload",{}).get("g",m) if isinstance(m.get("payload"),dict) else m,flush=True))
sc.load(); time.sleep(0.5)
emu.tap(700,730); time.sleep(5)
print("[GO]",flush=True); emu.tap(1355,960); time.sleep(35)
emu.screenshot(); import shutil; shutil.copy("/root/ants/_emu.png","/root/ants/noptostate.png")
print("done",flush=True)
