https://github.com/lovebirdsx/chatgpt-cli-extension
ChatGPT cli extension for google chrome.
https://github.com/lovebirdsx/chatgpt-cli-extension
chatgpt cli extension-chrome googlechrome
Last synced: 2 months ago
JSON representation
ChatGPT cli extension for google chrome.
- Host: GitHub
- URL: https://github.com/lovebirdsx/chatgpt-cli-extension
- Owner: lovebirdsx
- Created: 2025-05-20T12:59:16.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-30T04:34:24.000Z (about 1 year ago)
- Last Synced: 2025-06-28T03:02:08.177Z (about 1 year ago)
- Topics: chatgpt, cli, extension-chrome, googlechrome
- Language: JavaScript
- Homepage:
- Size: 54.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ChatGPT CLI Connector
This project allows you to control the ChatGPT web interface (`https://chatgpt.com/`) from your command-line interface (CLI). It enables sending messages, starting new chats, deleting conversations, and stopping message generation directly from the terminal.
## Overview
The project consists of three main components:
1. **Chrome Extension**: Injects a content script into the ChatGPT page to interact with its elements and listens for commands from the native host.
* `manifest.json`: Defines the extension, its permissions, and scripts.
* `background.js`: Service worker that manages communication between the content script and the native messaging host.
* `content.js`: Interacts with the ChatGPT DOM to perform actions like typing messages, clicking buttons, etc.
* `icons/`: Contains icons for the extension.
2. **Native Messaging Host**: A Node.js application that acts as a bridge between the Chrome extension (via standard I/O) and the CLI tool (via an HTTP server).
* `native-host/chatgpt-native-host.js`: The core logic of the native host. It listens for messages from the extension and exposes an HTTP endpoint for the CLI.
* `native-host/run-native-host.bat`: A batch script to execute the native host. The extension's manifest points to this.
* `native-host/lovebird.chatgpt_native_host.json` (Generated by `install.js`): The manifest file that Chrome uses to find and run the native host.
3. **CLI Tool**: A Node.js script that provides command-line access to control ChatGPT.
* `cli.js`: Parses command-line arguments and sends them as HTTP requests to the native messaging host.
* `chatgpt-cli.bat`: A batch script for conveniently running the `cli.js` script.
## Features
* **Select Model**: Choose between different ChatGPT models (1-5), injects the model selection into the ChatGPT page.
* Shortcut is `Alt + 1-5`.
* **Toggle Skill**: Toggle by different ChatGPT skills (1-4), like `Create an image`, `Search the web`, `Write or code`, and `Run deep research`.
* Shortcut is `Ctrl + Alt + 1-4`.
* **Search conversations**: Search for existing chats by name.
* Chatgpt default shortcut is `Ctrl + K` to open the search bar, but is conflicting with the browser's search functionality. Use `Alt + K` to open the search bar instead.
* **Send Messages**: Send prompts to ChatGPT from your terminal.
* **New Chat**: Start a new conversation.
* **Delete Chat**: Delete the current conversation.
* **Stop Generation**: Stop ChatGPT from generating a response.
* Shortcut is `Alt + S` to stop generation.
* **Ping**: Test the connection to the extension.
## Architecture Flow
* User runs a command via `chatgpt-cli.bat` (e.g., `chatgpt-cli sendMessage "Hello"`).
* `chatgpt-cli.bat` executes `cli.js` with the provided arguments.
* `cli.js` sends an HTTP POST request to the **Native Messaging Host** (`native-host/chatgpt-native-host.js`) listening on `http://localhost:3333/command`.
* The **Native Messaging Host** receives the HTTP request.
* It then sends the command to the **Chrome Extension's `background.js`** script via the Native Messaging protocol (standard input/output).
* `background.js` relays the command to the **`content.js`** script injected into the active ChatGPT tab.
* `content.js` simulates user interaction on the ChatGPT webpage (e.g., typing text, clicking buttons).
* `content.js` sends a response/status back to `background.js`.
* `background.js` sends this response back to the **Native Messaging Host**.
* The **Native Messaging Host** sends this response back as an HTTP response to `cli.js`.
* `cli.js` prints the response to the terminal.
## Prerequisites
* [Node.js](https://nodejs.org/) installed (for the CLI tool and Native Host).
* Google Chrome browser.
* Windows Operating System (as the installation scripts are primarily for Windows).
## Installation
Follow the instructions in [INSTALL.md](./INSTALL.md).
## Usage
Once installed, you can use the `chatgpt-cli` command from any command prompt. Ensure a ChatGPT tab (`https://chatgpt.com/`) is open in Chrome.