Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bazaarvoice/swat-proxy

A node.js proxy server that makes injecting applications or prototype applications onto potential client websites easy.
https://github.com/bazaarvoice/swat-proxy

Last synced: 2 months ago
JSON representation

A node.js proxy server that makes injecting applications or prototype applications onto potential client websites easy.

Awesome Lists containing this project

README

        

[![Build Status](https://travis-ci.org/bazaarvoice/swat-proxy.svg?branch=master)](https://travis-ci.org/bazaarvoice/swat-proxy)

# swat-proxy

swat-proxy is a tool to easily inject content, such as Javascript web applications,
onto third party web pages. This is useful in the development of applications
intended for third party use. It can also be useful in establishing a general
proxy server for use in applications that might need to regularly transform
requested content.

swat-proxy acts as a man-in-the-middle between browser and server, altering the
server response for specified pages. The browser renders the modified response
as if it came directly from the server itself. This allows viewing and
interacting with content on the target page.

The name swat-proxy derives from the name of the Small Web-Apps Technology team
whose members built the first iteration of this tool.

## Installation

```bash
npm install swat-proxy
```

## Quick Start

### Write a script that runs the Proxy

```js
/* Filename: do-proxy.js */

// Import swat-proxy.
var swat_proxy = require('swat-proxy');

// Add some JS to the end of the Google homepage.
swat_proxy.proxy('http://www.google.com/', {
selector: 'body',
manipulation: swat_proxy.Manipulations.APPEND,
content: ' alert ("Hello from swat-proxy!"); '
});

// Start the proxy server.
swat_proxy.start();
```

### Run your Script

```bash
node do-proxy.js
```

By default swat-proxy runs on port `8063` so set your browser to use the proxy
at `127.0.0.1:8063` and navigate to `http://www.google.com/`.

You should be immediately presented with the greeting alert, and you can
`View Page Source` to see that the Javascript was inserted before the closing
body tag (`