Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Latest commit

 

History

History
138 lines (110 loc) · 5.5 KB

README-en.md

File metadata and controls

138 lines (110 loc) · 5.5 KB

A browser extension to modify HTTP requests :-)

At first, Gooreplacer is created for redirecting Google Ajaxs/APIs/Fonts to other CDN to bypass Great Firewall, since pages referring those are slow as molasses.

Nowadays, more features have been added to gooreplacer, mainly:

  1. Block request
  2. Modify headers
  3. Export/Import rules, sync between Firefox/Chrome/Edge...
  4. Live Test
  5. i18n

Most users prefer gooreplacer than other similar extensions, HTTPS Everywhere/Redirector, for ease-of-use. Why not give it a try?

Install

Browser Rate User
Chrome Web Store Chrome Web Store Chrome Web Store
Mozilla Add-on Mozilla Add-on Mozilla Add-on
Microsoft Edge Microsoft Edge

Guides

Currently gooreplacer support 4 functions. Take one exported rules as example:

{
  "createBy": "https://github.com/jiacai2050/gooreplacer",
  "version": "2.0",
  "createAt": "Sun Oct 29 2017 19:55:32 GMT+0800 (CST)",
  "redirect-rules": [
    {
      "src": "ajax.googleapis.com",
      "dst": "ajax.proxy.ustclug.org",
      "kind": "wildcard",
      "enable": true
    }
  ],
  "cancel-rules": [
    {
      "src": "facebook.com",
      "kind": "wildcard",
      "enable": true
    }
  ],
  "request-headers": [
    {
      "src": "google.com",
      "kind": "wildcard",
      "name": "user-agent",
      "value": "gooreplacer",
      "op": "modify",
      "enable": true
    }
  ],
  "response-headers": [
    {
      "src": "google.com",
      "kind": "wildcard",
      "name": "Cookie",
      "op": "cancel",
      "enable": true
    }
  ]
}
  • redirect-rules used for redirects
  • cancel-rules used for blocks
  • request-headers used for modify/cancel http request headers
  • response-headers used for modify/cancel http response headers

In each rule,

  • src limit which request it will work on, and it has two types: wildcard and regexp, which is defined in kind key.
  • dst only required in redirects, means destination
  • enable turn on/off
  • op required in request-headers response-headers, has two enum value: cancel or modify
  • name, value required in request-headers response-headers, means header name(case-insensitive), header value

In redirects, you can use $1 $2 ... to backreference captured groups in case of regexp kind. For example:

{
  "src": "https://search.yahoo.com/search\?p=([a-z]+)",
  "dst": "https://www.google.com/search?q=$1",
  "kind": "regexp",
  "enable": true
}

Then https://search.yahoo.com/search?p=gooreplacer will redirect to https://www.google.com/search?q=gooreplacer

If your rules don't work as expected, use sandbox to test, it can tell what's missing.

NOTE

  • In order to be compatiable with old versions, redirect-rules key in JSON-rules file can be just rules and have following format:

    "rules": {
      "ajax.googleapis.com": {
        "dstURL": "ajax.proxy.ustclug.org",
        "enable": true,
        "kind": "wildcard"
      }
    }
    
  • According to Google Extension document,headers below can't be modified:

    • Authorization
    • Cache-Control
    • Connection
    • Content-Length
    • Host
    • If-Modified-Since
    • If-None-Match
    • If-Range
    • Partial-Data
    • Pragma
    • Proxy-Authorization
    • Proxy-Connection
    • Transfer-Encoding

Development

Gooreplacer is written in pure JavaScript before v1.0, you can check this version at legacy-js-src. After v2.0, gooreplacer get a big rewrite in ClojureScript + Reagent + Antd + React-Bootstrap,which is resident in cljs-src

License

MIT License © Jiacai Liu