XHook-XHR -


MIT
跨平台
JavaScript

软件简介

XHook 可轻松的修改 XHR 的请求和响应。主要用于:

  • Cache requests in memory, localStorage, etc.

  • Insert authentication headers

  • Simulate responses

    • Create fake transparent backends for testing purposes
  • Sending Error statistics to Google Analytics

  • Polyfil CORS, by offloading requests to an iframe then splicing the response back in, see XDomain

  • Devious practical jokes

  • Preflight GZip compression, see XZip (In progress)

示例代码:

//modify 'responseText' of 'example2.txt'
xhook.after(function(request, response) {
  if(request.url.match(/example\.txt$/)) 
    response.text = response.text.replace(/[aeiou]/g,'z');
});

支持的浏览器:IE8+, Chrome, Firefox, Safari