code wiki / _hdl_build / nx_domseed_test.nx

nx_domseed_test.nx source

↩ module page · 18 lines · 1166 B

1// nx_domseed_test.nx -- controlled proof that the sniff now seeds the page HTML as the DOM: an element carries a 2// data-* stream URL; inline JS reads it via document.getElementById(...).getAttribute(...) and fetch()es it. If the 3// DOM seed works, getElementById resolves the element, getAttribute returns the m3u8, fetch registers it, and the 4// harvest surfaces ROUTE=hls. If the DOM is NOT seeded, getElementById returns null -> TypeError -> ROUTE=none. 5import "nx_syscalls.nx" 6import "nx_video_sniff.nx" 7 8func cw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 9func tslen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } 10 11func main() -> i64 { 12 let html: *u8 = "<html><body><div id='pw' data-src='https://cdn.example.com/master.m3u8'></div><script>var e=document.getElementById('pw');var u=e.getAttribute('data-src');fetch(u);</script></body></html>" as *u8 13 let empty: *u8 = "" as *u8 14 let plan: *u8 = sys_mmap(2560) 15 let k: i64 = vs_sniff_page_bundled_pre(empty, 0, html, tslen(html), empty, 0, plan, 2560, 5) 16 cw("DOMSEED PLAN: " as *u8); cw(plan); cw("\n" as *u8) 17 return 0 18}