choonkeat / sotong

yet another Ruby proxy server

This URL has Read+Write access

sotong /
name age message
file README.rdoc Loading commit data...
directory scripts/
file sotong.rb
directory vendor/
README.rdoc

Intro

"Sotong" is yet another Ruby proxy server.

Goals

  1. easily modify any HTTP response before reaching my browser
  2. quick edit-save-refresh cycle
  3. avoid installing mouseHole & reading its documents

Get Started

  1. Set your browser to use a proxy at localhost:12345
  2. Execute command:
  $ ruby sotong.rb
  Proxy ready on 0.0.0.0:12345. Ctrl-C to quit.

Usage

To do more than just web proxy, add some arguments to the shell command:

  ruby sotong.rb <url regexp> <ruby script> [<url regexp> <ruby script> [<url regexp> <ruby script> ...]]

Example

The following command will run "scripts/google.rb" for any URL matching "google-analytics"

  $ ruby sotong.rb google-analytics scripts/google.rb
  URLs matching /google-analytics/ will trigger script "scripts/google.rb"
  Proxy ready on 0.0.0.0:12345. Ctrl-C to quit.

The following command will also run "scripts/nocache.rb" for any URL matching "swf"

  $ ruby sotong.rb google-analytics scripts/google.rb swf scripts/nocache.rb
  URLs matching /google-analytics/ will trigger script "scripts/google.rb"
  URLs matching /swf/ will trigger script "scripts/nocache.rb"
  Proxy ready on 0.0.0.0:12345. Ctrl-C to quit.

See scripts/inspect.rb

Example 2

  1. Setup your browser to use proxy at 0.0.0.0:12345
  2. Run sotong with "scripts/highlight-my-tweets.rb"
  $ ruby sotong.rb twitter.com/home scripts/highlight-my-tweets.rb
  URLs matching /twitter.com/home/ will trigger script "scripts/highlight-my-tweets.rb"
  Proxy ready on 0.0.0.0:12345. Ctrl-C to quit.
  1. Point your browser to twitter.com/home
  2. You should see your own tweets in yellow background.

This is just a simple illustration of what you can do

  1. tweak even when server-side environment is not accessible
  2. experiment without requiring firebug
  3. not limited to document.ready, javascript changes. e.g. http headers: gzip? resize image?