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{Interceptor.attach(b.add(0x5f54ca),{onLeave:function(r){send({g:"DisconnectTimeout="+r.toInt32()});}});}catch(e){send({g:"e "+e});}
 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(4); emu.tap(1355,960); time.sleep(8); print("done",flush=True)
