import frida, time, subprocess, sys
sys.path.insert(0,"/root/ants"); import emu
JS=r"""
function sstr(p){try{if(p.isNull())return "null";var n=p.add(8).readS32();if(n<0||n>200)return "?";return p.add(0xc).readUtf16String(n);}catch(e){return "ERR";}}
function ins(){var m=Process.findModuleByName("libil2cpp.so");if(!m)return false;var b=m.base;
 function H(a,nm){try{Interceptor.attach(b.add(a),{onEnter:function(){send({g:nm});}});}catch(e){}}
 H(0xd85e37,"PIERole.Start");H(0xd85ec9,"PIERole.WaitForMeta");H(0xd85f5b,"PIERole.EnableControls");
 H(0xd85fc5,"PIERole.CreateMatch");H(0xd860ba,"PIERole.OnSelectSniper");H(0xd8616f,"PIERole.OnSelectThief");
 try{Interceptor.attach(b.add(0x7947d4),{onEnter:function(){var sp=this.context.esp;send({g:"LoadSceneAsync '"+sstr(sp.add(4).readPointer())+"'"});}});}catch(e){}
 H(0xe47cab,"GC.Awake");H(0xe4bd6a,"SpawnPlayers");
 send({g:"__ready"});return true;}
if(!ins()){var iv=setInterval(function(){if(ins())clearInterval(iv);},100);}
"""
t=emu.launch_to_menu(); print("menu",int(t) if t else "FAIL",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",""),flush=True) if isinstance(m.get("payload"),dict) else None)
sc.load(); time.sleep(0.5)
print("[tap SNIPER]",flush=True); emu.tap(700,730); time.sleep(6)
print("[tap GO]",flush=True); emu.tap(1355,960); time.sleep(30)
print("done",flush=True)
