# @bringweb3/chrome-extension-kit 中文文档

规范地址：https://npmcn.com/package/%40bringweb3/chrome-extension-kit/

版本：1\.9\.0
npm 元数据更新时间：2026-09-17T10:52:51.912Z
中文译文更新时间：2026-11-08T15:35:59.038Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40bringweb3/chrome-extension-kit
原文对照：https://npmcn.com/package/%40bringweb3/chrome-extension-kit/?lang=original
项目主页：https://github.com/Bring-Web3-LTD/chromeExtension#readme
源码仓库：https://github.com/Bring-Web3-LTD/chromeExtension

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：116 kB，6 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：0 个
- 首次发布：2024-08-20T10:11:14.430Z
- 最新版本发布：2026-09-17T10:52:51.582Z
- 近 30 天下载量：2844（2026-10-09 至 2026-11-07，npm 官方下载统计）
- 已发布版本数：69（近 12 个月 8 个）

## 中文简介

用于加密插件扩展的加密现金组合包

## 安装

```sh
npm install @bringweb3/chrome-extension-kit
```

也可以使用：`pnpm add @bringweb3/chrome-extension-kit`、`yarn add @bringweb3/chrome-extension-kit`、`bun add @bringweb3/chrome-extension-kit`

## README

[![](https://media.bringweb3.io/logos/logo_doc.png)](https://bring.network/)

# @bringweb3/chrome-extension-kit (英语)

## 说明

@bringweb3/chrome-extension-kit为Chrome扩展钱包添加加密取款功能提供了一个强大的预配置框架. 这个SDK是为了无缝集成而设计的,一旦添加到钱包中,它就自主地处理从在线购买中获取的加密现金回放的整个周期.

### SDK 软件

这个SDK由一组JavaScript文件组成,可以将加密钱包整合到他们的Chrome扩展钱包中. 这种整合有利于无缝地添加现金回放功能,使得钱包用户可以在日常网上购物中获得加密现金回放. 当用户访问支持在线零售商网站时,Crypto Cashback系统根据用户的位置和网站的相关性确定现金回馈报价的资格. 如果是一个支持的商贩/零售商,用户将能够激活报价,并在购买时获得加密现金回购.

### 现金回收科

整合还包括钱包中一个专门的Cashback科,由Bring团队根据你的SDK建造. 请提供 SDK ,以使用户能够将其数字钱包连接到 [带上](https://bring.network/#contact)。 。 。 . 一旦整合, **带上** 将专门与现金回收科联系。 您可以在您的应用程序中浮出这个链接,让用户快速,无缝地访问他们的个性化奖励和状态仪表板.

## 先决条件

-   节点.js 14
-   带有必要权限的 Chrome 扩展显示 QQ V2
-   从 [带上](https://bring.network/#contact)
-   提供钱包的特定标志

## 安装

### 软件包

使用 npm :

```bash
$ npm install @bringweb3/chrome-extension-kit
```

使用线条 :

```bash
$ yarn add @bringweb3/chrome-extension-kit
```

使用 pnpm :

```bash
$ pnpm add @bringweb3/chrome-extension-kit
```

### 声明

将此配置包含在您的内部 `manifest.json` 文件 :

```json
  "permissions": [
    "storage",
    "tabs",
    "webNavigation",
    "webRequest"
  ],
  "content_scripts": [
    {
      "matches": [
        "<all_urls>"
      ],
      "js": [
        "contentScript.js" // The name of the file importing the bringContentScriptInit
      ],
      "all_frames": true
    }
  ],
  "host_permissions": [
    "http://*/*",
    "https://*/*"
  ]
```

## 导入

软件包安装后,您可以使用 `import` 或者说 `require` 办法:

```js
import { bringInitBackground } from '@bringweb3/chrome-extension-kit';
import { bringInitContentScript } from '@bringweb3/chrome-extension-kit';
```

```js
const { bringInitBackground } = require('@bringweb3/chrome-extension-kit');
const { bringInitContentScript } = require('@bringweb3/chrome-extension-kit');
```

## 示例

### 背景情况.js

```js

import { bringInitBackground } from '@bringweb3/chrome-extension-kit';

bringInitBackground({
    // ── MANDATORY ────────────────────────
    // identifier key obtained from Bring
    identifier: process.env.PLATFORM_IDENTIFIER,
    apiEndpoint: 'sandbox', // 'sandbox' | 'prod'

    // ── OPTIONAL ─────────────────────────
    // relative path to your Cashback Dashboard inside the extension
    cashbackPagePath: '/wallet/cashback',
    /* Route every Bring API call through your own backend instead of api.bringweb3.io.
       This is the full endpoint — Bring's host and paths are not appended, so every
       request goes to exactly this URL and your backend decides where it goes next.
       Use https: the requests carry your identifier and the user's wallet address.
       A value that isn't a valid URL throws at init. Omit it to use Bring's API directly. */
    baseUrl: 'https://api.partner.com/bring',
})
```

### 自办门户网站

如果您在自己的域上主机“带路”门户,该域必须被允许与 sDK号 允许入境的条件是: `/domains` 反应——送出基地 域名( 例如). `partner.com`,覆盖 `rewards.partner.com`)并会相加. 匹配 在主机上,所以这个办法和路径不重要,但一个端口确实如此:一个传送门在一个 非默认端口必须与它一起列出(例如:. `http://localhost:5173`) (中文(简体) ). 没有什么可设置的 扩展.

### 内容脚本.js

```js
import { bringInitContentScript } from "@bringweb3/chrome-extension-kit";

bringInitContentScript({
    // ── MANDATORY ────────────────────────
    // Async function that returns the current user's wallet address
    getWalletAddress: async () => ...,
    // function that prompts the user to log in
    promptLogin: () => {...},

    // ── MANDATORY (pick one) ────────────
    // An optional list of custom events that dispatched when the user's wallet address had changed
    // Don't add it if you are using walletAddressUpdateCallback
    walletAddressListeners: ["customEvent:addressChanged"],
    // An optional function that runs when the user's wallet address had changed and execute the callback
    // Don't add it if you are using walletAddressListeners
    walletAddressUpdateCallback: (callback) => {...},

    // ── OPTIONAL ─────────────────────────
    // 'lower' | 'upper' (defaults to 'lower')
    text: 'lower',
    // 'light' | 'dark' (defaults to 'light')
    theme: 'light',
    // show a switch-wallet button (requires a wallet-change UI)
    switchWallet: true,
    /* needed if you want to host the style file on your own servers.
    styleUrl examples:
      - Single theme: https://media.bringweb3.io/examples/style/theme-single.json
      - Dark & light: https://media.bringweb3.io/examples/style/theme-dual.json
      If not provided (recommended), Bring will host the style. */
    styleUrl: 'https://<your-domain>',
});
```

### 转折设置

```javascript
import { getTurnOff, setTurnOff } from "@bringweb3/chrome-extension-kit";

// Get state example
const current = await getTurnOff()
console.log(current) // true | false

// Set state example
const res = await setTurnOff(true)
console.log(res.isTurnedOff) // true
```

## 联系我们

更多信息: [联系我们](https://bring.network/#contact)

## 常见问题

### @bringweb3/chrome-extension-kit 是什么？

用于加密插件扩展的加密现金组合包

### 如何安装 @bringweb3/chrome-extension-kit？

在项目目录运行 npm install @bringweb3/chrome-extension-kit，或使用 pnpm add / yarn add / bun add。

### @bringweb3/chrome-extension-kit 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @bringweb3/chrome-extension-kit 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @bringweb3/chrome-extension-kit 可以商用吗？

@bringweb3/chrome-extension-kit 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @bringweb3/chrome-extension-kit 的下载量有多少？

根据 npm 官方下载统计，@bringweb3/chrome-extension-kit 在 2026/10/09 – 2026/11/07 这 30 天内被下载 2,844 次，日均约 95 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @bringweb3/chrome-extension-kit 还在维护吗？

最新版本 1\.9\.0 发布于 2026/09/17（1 个月前）；至今共发布 69 个版本，其中过去 12 个月发布了 8 个；首次发布于 2024/08/20。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

