Skip to content

Repository files navigation

lemon cha Browser Extension

简体中文

lemon cha is a lightweight Chrome and Firefox extension that opens a dedicated AI chat tab for two kinds of model providers:

  • Custom LLM APIs that use an OpenAI Chat Completions-compatible format.
  • Local Ollama models, with http://127.0.0.1:11434/api/chat as the default endpoint.
  • Requests are sent from the browser extension background context.
  • Local Ollama requests include a direct-connect fallback that normalizes the local origin path.
  • The interface supports streaming output, stop generation, Markdown rendering, copyable code blocks, multi-session history, folders, rename/delete actions, Markdown export, and JSON import/export.

Install locally in Chrome

  1. Open Chrome and visit chrome://extensions/.
  2. Enable Developer mode.
  3. Click "Load unpacked".
  4. Select dist/lemon-cha after running npm run build:chrome.
  5. Click the extension action to open lemon cha in a dedicated browser tab.

Install locally in Firefox

  1. Run npm run build:firefox.
  2. Open Firefox and visit about:debugging#/runtime/this-firefox.
  3. Click "Load Temporary Add-on...".
  4. Select dist/lemon-cha-firefox/manifest.json.
  5. Click the extension action to open lemon cha in a dedicated browser tab.

Development checks

lemon cha is a lightweight Manifest V3 extension without a frontend bundler. The repository uses npm scripts for validation and packaging:

npm run lint
npm run typecheck
npm run build
  • npm run lint: validates required extension files, Chrome and Firefox Manifest V3 setup, HTML asset references, and JavaScript syntax.
  • npm run typecheck: runs a lightweight syntax-oriented validation pass for this vanilla JavaScript project.
  • npm run build: copies runtime files into dist/lemon-cha for Chrome and dist/lemon-cha-firefox for Firefox.
  • npm run build:chrome: builds only the Chrome package.
  • npm run build:firefox: builds only the Firefox package.

Firefox uses the same runtime code with a generated Firefox manifest. The generated manifest swaps Chrome's background.service_worker for Firefox's background.scripts and adds Gecko extension settings required for Firefox distribution.

Custom API settings

Choose the custom API workflow and configure:

  • Endpoint, for example https://api.openai.com/v1/chat/completions
  • Model name, for example gpt-4o-mini
  • API key, if the provider requires one
  • API format: OpenAI Chat Completions or Ollama /api/chat
  • Thinking mode behavior
  • Interface language, answer language, and default translation target language

If the API format is OpenAI-compatible and the endpoint only contains the domain or /v1, lemon cha completes it to /v1/chat/completions. Provider-specific paths can still be entered manually.

Built-in provider presets include DeepSeek, OpenAI, Qwen DashScope, Kimi, SiliconFlow, OpenRouter, Groq, and local Ollama.

Conversation management

  • Create new conversations.
  • Switch between saved chats from the sidebar.
  • Organize chats inside folders.
  • Rename or delete conversations.
  • Export the current chat as Markdown.
  • Import or export JSON records containing conversations, settings, and custom prompt presets.
  • Clear history or restore factory defaults from the data settings area.

Message actions

Each assistant or user message can expose compact actions such as:

  • Copy
  • Regenerate
  • Continue from here
  • Delete

Connection checks

The connection checker supports:

  • Ollama /api/tags for model discovery and reachability checks
  • OpenAI-compatible lightweight test requests for endpoint, model, and API key verification

Generation experience

  • Streaming model responses
  • Stop generation while preserving partial output
  • Dynamic waiting state for slower local models
  • Generation timing and approximate token metrics
  • Automatic first-turn conversation title generation
  • Markdown rendering for paragraphs, lists, emphasis, code blocks, and tables
  • Copy button inside code blocks
  • Persistent bottom composer for long conversations
  • Collapsible sidebar for a cleaner reading surface

Prompt presets

The composer includes reusable prompt presets:

  • Summarization
  • Translation and polishing
  • Code review
  • Troubleshooting
  • Writing revision
  • Task planning

Built-in templates are localized for Simplified Chinese, Traditional Chinese, English, Japanese, Korean, French, Spanish, and German.

When a preset is applied:

  • If the composer is empty, lemon cha replaces the input and selects the first {placeholder}.
  • If the composer already contains text, lemon cha asks before replacing it.
  • Translation presets can resolve the default translation target language selected in Settings.

Ollama setup

Start Ollama and install a local model:

ollama serve
ollama pull llama3.1

Default lemon cha settings:

  • Endpoint: http://127.0.0.1:11434/api/chat
  • Model: llama3.1

Connection strategy:

  • localhost is normalized to 127.0.0.1.
  • /api/tags is used for model listing and connectivity tests.
  • /api/chat is used for multi-turn chat and streaming.
  • Local Ollama requests are handled from the extension background context.

Ollama 403 / Origin rejection

If Ollama rejects the browser extension origin, restart Ollama with extension-origin allowance.

macOS Ollama app:

launchctl setenv OLLAMA_ORIGINS "chrome-extension://*,moz-extension://*"

Quit the Ollama menu bar app completely, then open it again.

macOS/Linux command line:

OLLAMA_ORIGINS="chrome-extension://*,moz-extension://*" ollama serve

Temporary broad debug option:

OLLAMA_ORIGINS="*" ollama serve

Windows PowerShell:

$env:OLLAMA_ORIGINS="chrome-extension://*,moz-extension://*,http://localhost:*,http://127.0.0.1:*"
ollama serve

Repository layout

  • manifest.json: source Chrome Manifest V3 configuration
  • scripts/build-extension.js: Chrome and Firefox extension package builder
  • background.js: background networking and provider calls
  • chat.html: dedicated chat page
  • styles.css: visual system and responsive layout
  • popup.js: state, settings, conversations, and UI flows
  • chrome-store/: Chrome Web Store listing, privacy, review, and release materials

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages