code wiki / _hdl_build / nx_click_test.nx

nx_click_test.nx source

↩ module page · 24 lines · 1528 B

1// nx_click_test.nx -- isolate the INTERACTION TRIGGER: a click-to-load player (fetch inside an addEventListener 2// 'click' handler bound synchronously). vs_sniff_net_bundled appends the auto-click postamble. If click fires the 3// listener, fetch(m3u8) registers -> recorded as media -> ROUTE=hls. If HTML-seeded click can't match the listener, 4// ROUTE=none (=> the trigger needs DOM_TREE mode, not the lazy HTML-seeded view). 5import "nx_syscalls.nx" 6import "nx_x509_trust_store.nx" 7import "nx_trust_store_load_from_certdata.nx" 8import "nx_video_sniff.nx" 9import "nx_video_sniff_fetch.nx" 10 11func cw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 12func tslen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } 13 14func main() -> i64 { 15 let r: i64 = nx_trust_store_load_from_certdata("data/mozilla_certdata.txt" as *u8, 512, 4194304) 16 if r <= 0 { cw("certdata load failed\n" as *u8); sys_exit(1); return 1 } 17 let store: *TrustStore = r as *TrustStore 18 let html: *u8 = "<div id='player-wrapper' data-src='https://cdn.example.com/master.m3u8'></div><script>document.getElementById('player-wrapper').addEventListener('click',function(){var u=document.getElementById('player-wrapper').getAttribute('data-src');fetch(u);});</script>" as *u8 19 let empty: *u8 = "" as *u8 20 let plan: *u8 = sys_mmap(2560) 21 vs_sniff_net_bundled(empty, 0, html, tslen(html), empty, 0, store, plan, 2560, 4) 22 cw("CLICK PLAN: " as *u8); cw(plan); cw("\n" as *u8) 23 return 0 24}