Skip to content

pilipala233/ApiPatcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

ApiPatcher

English | 中文


English

ApiPatcher is a powerful Chrome extension designed for developers to intercept and modify HTTP requests and responses on the fly.

Features

  • Modify Request Headers: Add or overwrite headers (e.g., Origin, Referer, Authorization) for specific URLs.
  • Modify Request Body: Inject custom JSON payloads into POST/PUT requests.
  • Modify Response Body: Mock server responses by replacing the returned JSON data with your own.
  • Modify Response Headers: Overwrite response headers (e.g., Access-Control-Allow-Origin) to fix CORS issues during development.
  • Zero Config: Works immediately with a simple UI.
  • Regex Support: Target URLs using substring matching (regex support coming soon).

Installation

  1. Clone this repository or download the source code.
  2. Open Chrome and navigate to chrome://extensions.
  3. Enable Developer mode in the top right corner.
  4. Click Load unpacked and select the project directory.

Usage

  1. Click the ApiPatcher icon in the toolbar.
  2. Manage Rules:
    • You will see a list of your configured rules.
    • Click + New Rule to create a new interception rule.
    • Use the toggle switch in the list to quickly Enable/Disable a rule.
  3. Configure a Rule:
    • Target URL: Enter a substring of the URL you want to patch (e.g., api/v1/user).
    • Request Headers: Add custom headers to inject.
    • Request Body: Set a JSON payload to override the request body.
    • Response Body: Set a JSON payload to mock the server response.
    • Response Headers: Add response headers (e.g., to fix CORS).
    • Click Save Rule to apply changes.
  4. Apply Changes:
    • Changes are saved immediately. Refresh your target page to see them in effect.

中文 (Chinese)

ApiPatcher 是一款专为开发者设计的 Chrome 插件,用于实时拦截和修改 HTTP 请求与响应。

功能特性

  • 多规则支持: 同时管理多个不同的拦截规则,独立配置。
  • 修改请求头 (Request Headers): 为特定 URL 添加或覆盖请求头(如 Origin, Referer, Authorization)。
  • 修改请求体 (Request Body): 向 POST/PUT 请求中注入自定义的 JSON 数据。
  • 修改响应体 (Response Body): 通过替换返回的 JSON 数据来 Mock 服务器响应。
  • 修改响应头 (Response Headers): 覆盖响应头(如 Access-Control-Allow-Origin),轻松解决开发时的 CORS 跨域问题。
  • 快速开关: 在规则列表中直接启用或禁用特定规则。
  • 零配置: 界面简单,即装即用。

安装步骤

  1. 克隆本仓库或下载源代码。
  2. 打开 Chrome 浏览器,访问 chrome://extensions
  3. 打开右上角的 开发者模式 (Developer mode)
  4. 点击 加载已解压的扩展程序 (Load unpacked),选择本项目文件夹。

使用指南

  1. 点击浏览器工具栏上的 ApiPatcher 图标。
  2. 管理规则:
    • 你会看到所有已配置规则的列表。
    • 点击 + New Rule 创建新规则。
    • 使用列表中的开关快速 启用/禁用 规则。
  3. 配置规则:
    • Target URL: 输入你想拦截的 URL 片段(例如 api/v1/user)。
    • Request Headers: 添加自定义请求头。
    • Request Body: 设置要覆盖的请求体数据。
    • Response Body: 设置要 Mock 的响应体数据。
    • Response Headers: 添加响应头(如解决跨域问题)。
    • 点击 Save Rule 保存。
  4. 应用更改:
    • 保存后立即生效。刷新目标页面即可看到效果。

About

一款专为开发者设计的 Chrome 插件,用于实时拦截和修改 HTTP 请求与响应

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published