/**
 * 本模块负责提供`XMLHttpRequest`的hook工具
 * 拦截`open`参数组并传入`XMLHttpRequest`对象本身给回调函数
 */ /**
 * 本模块负责提供`XMLHttpRequest`的hook工具
 * 拦截`open`参数组并传入`XMLHttpRequest`对象本身给回调函数
 */ ( function ( ) { try { const rules = [ ] ; const open = XMLHttpRequest . prototype . open ; API . xhrhook = ( url , callback ) => rules . push ( [ url , callback ] ) ; API . removeXhrhook = ( id ) => rules . splice ( id - 1 , 1 ) ; ( < any > XMLHttpRequest . prototype . open ) = function ( this , ... rest ) { let args = [ ... rest ] ; args [ 1 ] && rules . forEach ( d => { d [ 0 ] . every ( d => args [ 1 ] . includes ( d ) ) && d [ 1 ] . call ( this , args ) ; } ) ; return open . call ( this , ... args ) ; } ; } catch ( e ) { toast . error ( "open.js" , e ) ; } } ) ( ) ; declare namespace API { param url param callback returns function xhrhook ( url , callback ) ; param id function removeXhrhook ( id ) ; }