feat(extension): add popup UI, privacy policy, and CSP for Chrome Web Store (#415)

- Add popup.html/popup.js showing daemon connection status
  (Connected / Reconnecting / No daemon connected)
- Add message listener in background.ts to expose WebSocket state
- Add PRIVACY.md with full privacy policy covering all permissions
- Add content_security_policy to manifest.json
- Update description to be clearer for CWS reviewers
This commit is contained in:
jakevin
2026-03-25 15:07:40 +08:00
committed by GitHub
parent 15369fa23c
commit 4812486482
6 changed files with 665 additions and 519 deletions
+57
View File
@@ -0,0 +1,57 @@
# Privacy Policy — OpenCLI Browser Extension
**Last updated**: 2026-03-25
## What the extension does
The OpenCLI Browser Extension is a bridge between the [OpenCLI](https://github.com/jackwener/opencli) command-line tool and your Chrome browser. It receives commands from a **locally running daemon** process via WebSocket (`localhost` only) and executes them in **isolated Chrome windows** that are separate from your normal browsing session.
## Data collection
The extension does **NOT** collect, store, transmit, or sell any personal data. Specifically:
- **No analytics or telemetry** — no data is sent to any remote server.
- **No user tracking** — no cookies, identifiers, or fingerprints are created.
- **No external network requests** — all communication is strictly `localhost` (WebSocket to `ws://localhost:19825`).
## Permissions explained
| Permission | Why it's needed |
|------------|----------------|
| `debugger` | Required to use Chrome DevTools Protocol (CDP) for browser automation — executing JavaScript, capturing page content, and taking screenshots in isolated windows. |
| `tabs` | Required to create and manage isolated automation windows and tabs, separate from the user's browsing session. |
| `cookies` | Required to read site-specific cookies (scoped by domain) so CLI commands can authenticate with websites the user is already logged into. Cookies are **never written, modified, or transmitted externally**. |
| `activeTab` | Required to identify the currently active tab for context-aware commands. |
| `alarms` | Required to maintain the WebSocket connection to the local daemon via periodic keepalive checks. |
## Data flow
```
User's terminal (opencli CLI)
↓ (spawns)
Local daemon process (localhost:19825)
↓ (WebSocket, localhost only)
Chrome Extension (this extension)
↓ (Chrome APIs)
Isolated Chrome automation window
```
All data stays on the user's machine. No data leaves `localhost`.
## Cookie access
The extension reads cookies **only** when explicitly requested by a CLI command, and **only** for the specific domain the command targets. It cannot and does not dump all cookies. Cookie data is returned to the local daemon process and is never sent to any external server.
## Third-party services
This extension does not integrate with, send data to, or receive data from any third-party service.
## Open source
This extension is fully open source. You can audit the complete source code at:
https://github.com/jackwener/opencli/tree/main/extension
## Contact
For privacy questions or concerns, please open an issue at:
https://github.com/jackwener/opencli/issues
+506 -518
View File
File diff suppressed because it is too large Load Diff
+5 -1
View File
@@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "OpenCLI",
"version": "1.4.0",
"description": "Bridge between opencli CLI and your browser — execute commands, read cookies, manage tabs.",
"description": "Browser automation bridge for the OpenCLI CLI tool. Executes commands in isolated Chrome windows via a local daemon.",
"permissions": [
"debugger",
"tabs",
@@ -22,10 +22,14 @@
},
"action": {
"default_title": "OpenCLI",
"default_popup": "popup.html",
"default_icon": {
"16": "icons/icon-16.png",
"32": "icons/icon-32.png"
}
},
"content_security_policy": {
"extension_pages": "script-src 'self'; object-src 'self'"
},
"homepage_url": "https://github.com/jackwener/opencli"
}
+65
View File
@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
width: 280px;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
font-size: 13px;
color: #333;
background: #fff;
padding: 16px;
}
.header {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 14px;
}
.header img { width: 24px; height: 24px; }
.header h1 { font-size: 15px; font-weight: 600; }
.status-row {
display: flex;
align-items: center;
gap: 8px;
padding: 10px 12px;
border-radius: 8px;
background: #f5f5f5;
}
.dot {
width: 8px; height: 8px;
border-radius: 50%;
flex-shrink: 0;
}
.dot.connected { background: #34c759; }
.dot.disconnected { background: #ff3b30; }
.dot.connecting { background: #ff9500; }
.status-text { font-size: 13px; color: #555; }
.status-text strong { color: #333; }
.footer {
margin-top: 14px;
text-align: center;
font-size: 11px;
color: #999;
}
.footer a { color: #007aff; text-decoration: none; }
.footer a:hover { text-decoration: underline; }
</style>
</head>
<body>
<div class="header">
<img src="icons/icon-48.png" alt="OpenCLI">
<h1>OpenCLI</h1>
</div>
<div class="status-row">
<span class="dot disconnected" id="dot"></span>
<span class="status-text" id="status">Checking...</span>
</div>
<div class="footer">
<a href="https://github.com/jackwener/opencli" target="_blank">Documentation</a>
</div>
<script src="popup.js"></script>
</body>
</html>
+20
View File
@@ -0,0 +1,20 @@
// Query connection status from background service worker
chrome.runtime.sendMessage({ type: 'getStatus' }, (resp) => {
const dot = document.getElementById('dot');
const status = document.getElementById('status');
if (chrome.runtime.lastError || !resp) {
dot.className = 'dot disconnected';
status.innerHTML = '<strong>No daemon connected</strong>';
return;
}
if (resp.connected) {
dot.className = 'dot connected';
status.innerHTML = '<strong>Connected to daemon</strong>';
} else if (resp.reconnecting) {
dot.className = 'dot connecting';
status.innerHTML = '<strong>Reconnecting...</strong>';
} else {
dot.className = 'dot disconnected';
status.innerHTML = '<strong>No daemon connected</strong>';
}
});
+12
View File
@@ -193,6 +193,18 @@ chrome.alarms.onAlarm.addListener((alarm) => {
if (alarm.name === 'keepalive') connect();
});
// ─── Popup status API ───────────────────────────────────────────────
chrome.runtime.onMessage.addListener((msg, _sender, sendResponse) => {
if (msg?.type === 'getStatus') {
sendResponse({
connected: ws?.readyState === WebSocket.OPEN,
reconnecting: reconnectTimer !== null,
});
}
return false;
});
// ─── Command dispatcher ─────────────────────────────────────────────
async function handleCommand(cmd: Command): Promise<Result> {