# chrome-xhr-spy

> XHR spy for Chrome extensions

Latest version **0.1.0** (published 2016-12-15) · 0 weekly downloads

## Install

```sh
npm install chrome-xhr-spy
pnpm add chrome-xhr-spy
yarn add chrome-xhr-spy
bun add chrome-xhr-spy
```

## Health

**Score 10/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2016-12-15 |
| First published | 2016-12-15 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Cameron Lakenen |
| Maintainers | lakenen |

## Links

- npm: https://www.npmjs.com/package/chrome-xhr-spy
- Repository: https://github.com/lakenen/chrome-xhr-spy
- Issues: https://github.com/lakenen/chrome-xhr-spy/issues
- npm.io page: https://npm.io/package/chrome-xhr-spy

## Recent versions

- 0.1.0 (latest) — 2016-12-15

## README

# chrome-xhr-spy

XHR spy for Chrome extensions. **Warning: super hacky. Use at your own risk.**


## Installation

```
npm install chrome-xhr-spy
```


## Usage

`var spy = injectXHRSpy(config)`

* **config**
  * **modify** - whether or not to allow modifying the request or response data (this blocks the request until the passed callback is called).
  * **filter** - filter options for the request
    * **request** - whether to spy the request
    * **response** - whether to spy the response
    * **url** - object with URL filter options
      * **pathname** - string pathname to match (exact)
      * **search** - object with search params to match
    * **method** - the type of request to match ('GET', 'PUT', 'POST', etc)
  * **callback** - callback function to call with the form `function (data, info[, callback])`

#### Returns

Object with `remove` method that disables removes the spy.


Example
```js
var injectXHRSpy = require('chrome-xhr-spy')

var requestSpy = injectXHRSpy({
  filter: { request: true, pathname: '/api/v1/blah' },
  callback: function (requestData) {
    // does not block the request
    console.log(requestData)
  }
})
var responseSpy = injectXHRSpy({
  modify: true
  filter: { response: true, pathname: '/api/v1/blah' },
  callback: function (responseData, info, callback) {
    // blocks any response handlers from running until callback is called
    console.log(responseData)
    callback({ lol: 'no data 4 u' })
  }
})

// some time in the future...
requestSpy.remove()
responseSpy.remove()

```


## License

([The MIT License](LICENSE))

Copyright 2016 Emburse, Inc

---
_Source: https://npm.io/package/chrome-xhr-spy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
