← Back to Plugins
Tools

Send To Openclaw

mlazzarotto By mlazzarotto 👁 20 views ▲ 0 votes

Firefox + Chrome extension: send the current page or selection to OpenClaw and start a new chat

GitHub

Install

npm install
node

README

<p align="center">
  <img src="src/icons/icon128.png" width="96" alt="Send to OpenClaw">
</p>

<h1 align="center">Send to OpenClaw</h1>

<p align="center">
  <a href="https://github.com/mlazzarotto/send-to-openclaw/actions/workflows/build.yml"><img src="https://github.com/mlazzarotto/send-to-openclaw/actions/workflows/build.yml/badge.svg" alt="build"></a>
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License: MIT"></a>
  <a href="src/manifest.chrome.json"><img src="https://img.shields.io/badge/manifest-v3-brightgreen.svg" alt="Manifest V3"></a>
  <img src="https://img.shields.io/badge/node-%3E%3D22-informational.svg" alt="Node >= 22">
  <a href="https://github.com/mlazzarotto/send-to-openclaw/pulls"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="PRs welcome"></a>
  <!-- enable after publishing
  <a href="https://addons.mozilla.org/firefox/addon/send-to-openclaw/"><img src="https://img.shields.io/amo/v/send-to-openclaw?label=firefox" alt="Firefox AMO"></a>
  <a href="#"><img src="https://img.shields.io/chrome-web-store/v/EXTENSION_ID?label=chrome" alt="Chrome Web Store"></a>
  <a href="https://github.com/mlazzarotto/send-to-openclaw/releases"><img src="https://img.shields.io/github/v/release/mlazzarotto/send-to-openclaw" alt="Latest release"></a>
  -->
</p>

A browser extension (Firefox + Chrome) that takes the page you are on — or just the
text you selected — adds your prompt, and opens a **new OpenClaw chat** that starts
working on it.

No relay process, no local server: the extension talks to your gateway directly over
WebSocket, authenticated with a **device token** limited in scope.

## How it works

1. First pairing: paste your gateway token once.
2. The extension generates an **Ed25519** keypair (private key non-extractable, kept
   in IndexedDB), presents itself as a device, and receives a **device token**.
3. The gateway token is then deleted from storage; only the device token remains.
4. Every send calls `sessions.create { agentId, key: browser-<timestamp>, message }`.

The message sent to OpenClaw:

```
<your prompt>

---
From: <page title>
<url>

Selected text:      (or "Page text:")
<content>
```

The selection wins over extracted text (max 60,000 characters); without a selection
the extension uses `article` / `main` / `body`, up to 20,000 characters.

## Build

```bash
npm install
node build.mjs          # -> dist/chrome, dist/firefox
```

One codebase, two generated manifests (`src/manifest.chrome.json`,
`src/manifest.firefox.json`). The only real differences:

| | Chrome | Firefox |
| --- | --- | --- |
| background | `service_worker` | `scripts` (event page) |
| client id | `openclaw-browser-copilot` | `openclaw-linux` |
| origin | exempt (`chrome-extension://<a-p{32}>`) | must be in `allowedOrigins` |

## Install (development)

**Chrome** — `chrome://extensions` → Developer mode → Load unpacked → `dist/chrome`.

**Firefox** — `about:debugging#/runtime/this-firefox` → Load Temporary Add-on →
`dist/firefox/manifest.json`. A temporary add-on gets a new UUID on every load; for a
stable UUID sign the add-on (unlisted AMO) and the UUID stays fixed.

## Configuration

Only Firefox needs one config entry: add the extension origin (copy it from the
settings page) to the gateway origin allowlist.

```json5
{
  gateway: {
    controlUi: {
      allowedOrigins: [
        "https://claw.example.com",
        "moz-extension://<uuid>"
      ],
    },
  },
}
```

Chrome does not need it: the `openclaw-browser-copilot` client is exempt, but only with
a canonical `chrome-extension://` origin.

## Settings

- **Gateway** — the URL you use for the Control UI (`https://…`). If you omit the
  scheme, the extension probes both `https` and `http` and keeps the one that answers.
- **Agent** — defaults to `main`.
- **Gateway token** — used only for the first pairing, then removed automatically.
- **Scopes** — defaults to `operator.write`.

## Usage

- Toolbar icon → prompt → Send.
- Right-click on a page or a selection → "Send to OpenClaw".
- `Alt+Shift+S` opens the popup.

## Development checks

```bash
node test/bundle.mjs wrong   # a bad token must be rejected, not reported as connected
node test/bundle.mjs right   # pairing, status, and a real sessions.create call
node test/steady.mjs         # device-token reconnect without the gateway token
```

These run the built background bundle against a local gateway (`ws://127.0.0.1:18789`
by default) with browser shims, so they exercise the code that ships.

## Project layout

```
src/background.js        pairing, WebSocket client, page extraction, send
src/popup.*              toolbar popup
src/options.*            setup page
src/manifest.*.json      per-browser manifests
src/icons/               generated icon set
build.mjs                esbuild bundle + manifest + asset copy
test/                    Node harnesses against a real gateway
```

## Contributing

Issues and pull requests are welcome. Run `node build.mjs` before opening a PR, and
describe which browser you tested on.

## License

MIT © [Marco Lazzarotto](https://github.com/mlazzarotto/send-to-openclaw)
tools

Comments

Sign in to leave a comment

Loading comments...