Share

外观
风格

claude-chrome-hack

2026年2月7日 · 技术

Claude Chrome 扩展逆向工程

概述

逆向工程 Claude in Chrome 浏览器自动化扩展,使其支持 API Key 认证(替代 $200/月订阅)。

文件位置

  • 修改版扩展: ~/Downloads/claude-chrome-mod/
  • 原版参考: ~/Downloads/claude-chrome-ref/ (cocodem v1.0.36)

关键发现

cocodem 的方案

  1. 中央代理服务器: cfc.aroic.workers.dev
  2. OAuth 拦截: 把 claude.ai 的 OAuth 重定向到自己的服务器
  3. 配置下发: /api/options 返回运行时配置
  4. 需要激活码: 购买激活码才能使用

核心文件

文件 作用
request.js 核心!拦截 fetch 和 XHR,重定向 API 请求
client-BsbSyIlx.js 完整的 Anthropic JS SDK
permissions-DQjjgS8V.js React 组件和权限管理
manifest.json 扩展配置

认证机制

扩展内嵌的 Anthropic SDK 支持两种认证方式:

  • apiKey: 发送 X-Api-Key header
  • authToken: 发送 Authorization: Bearer xxx header

accessToken 存储在 chrome.storage.local,JWT 格式:

  • iss == "auth" 表示 API Key 模式
  • iss == "claude" 表示 OAuth 模式

我们的修改方案

修改 request.js

  1. 移除远程配置获取 - 不依赖 cocodem 服务器
  2. 默认 API Base - 使用 ai.chen.rs 作为网关
  3. OAuth 拦截 - 重定向到配置页面
  4. 追踪请求 - 直接丢弃 Segment/Sentry 等

配置方法

在扩展 Console 中执行:

// 设置 API 配置
chrome.storage.local.set({
  apiKey: "your-api-key",
  apiBaseUrl: "https://ai.chen.rs"
})

// 模拟登录状态
const fakeToken = btoa(JSON.stringify({iss: "auth", sub: "api-user"}))
chrome.storage.local.set({
  accessToken: "header." + fakeToken + ".signature",
  tokenExpiry: Date.now() + 365 * 24 * 3600 * 1000
})

已知问题

  1. 订阅检查 - 可能仍有服务端验证
  2. 浏览器自动化 - 需要 Claude Desktop 本地应用配合
  3. 更新问题 - 官方更新后需重新逆向

验证清单

  • 成功下载并解包扩展
  • 识别认证相关代码位置
  • 添加 API Key 配置
  • 扩展能正常加载 (待测试)
  • 基础对话功能正常
  • 浏览器自动化功能正常

工具命令

# 查看扩展目录
open ~/Downloads/claude-chrome-mod

# 打开 Chrome 扩展页面
open -a "Google Chrome" "chrome://extensions"