Skip to content

OpenTester007/Chat-with-KB

Repository files navigation

AI-based Translator

Microsoft Edge Add-ons License: MIT PRs Welcome

AI-powered translation, text polishing, bilingual dictionary, and chat assistant for Chinese, English, Japanese, and Korean. Published on the Microsoft Edge Add-ons store.

Extension Screenshot

Tip

Frictionless Setup (No API Key Required to Test!) If you want to test the extension immediately without registering an API key, simply go to the Settings (设置) tab and click the "导入测试密钥" (Import Test Key) link. This will automatically import a pre-configured, free, and fully functional API Key, Endpoint, and Model preset, allowing you to start translating and chatting instantly.

Overview

AI-based Translator is an open-source, Manifest V3 browser extension that lowers the barrier to LLM translation for Chinese, English, Japanese, and Korean users. It is published on the Microsoft Edge Add-ons store and actively maintained by a single core maintainer.

The extension solves a real friction point: most LLM-powered tools require users to register, obtain an API key, and configure endpoints before they can translate a single sentence. AI-based Translator ships with a one-click "导入测试密钥" (Import Test Key) feature, which provides a working demo key over HTTPS or a local fallback so users can test immediately without registration.

Features

  • Background Execution: Translation, polishing, dictionary, and chat requests run in a background service worker. Switching tabs or closing the popup will not interrupt active operations, and finished results are automatically saved to your history.
  • One-Click Demo Setup: Instantly populate working API configurations from settings via a remote HTTPS fetch or local Base64-encoded fallback.
  • Translation: Translate between Chinese, English, Japanese, and Korean. Auto-detects source language.
  • Text Polishing: Polish text and explain changes in Chinese.
  • Dictionary: Definitions, parts of speech, root/affix analysis, and bilingual example sentences.
  • Chat: Sidebar chat assistant with conversation memory.
  • History: Saves the last 10 translation records locally.

Installation

From Microsoft Edge Add-ons Store

Get from Edge Add-ons
  1. Click the badge above to open the Edge Add-ons store page.
  2. Click Get to install.

Sideload (Developer Mode)

  1. Clone this repository:
    git clone https://github.com/OpenTester007/Chat-with-KB.git
  2. Open edge://extensions/ in Microsoft Edge.
  3. Enable Developer mode.
  4. Click Load unpacked and select the cloned folder.
  5. Open the extension Settings tab, click "导入测试密钥" (Import Test Key) to auto-configure, or enter your own custom API Key.

Configuration

Setting Default Description
API Key empty Add your own NVIDIA Build or OpenAI-compatible provider key.
API Endpoint https://integrate.api.nvidia.com/v1 Customize for OpenAI-compatible providers. Remote endpoints must use HTTPS.
Model openai/gpt-oss-20b Choose from presets or enter any model ID.
Streaming On Toggle between real-time streaming and batch responses.

Supported Models (Presets)

Model Type
openai/gpt-oss-20b Reasoning (default)
deepseek-ai/deepseek-v4-flash Chat
meta/llama-3.3-70b-instruct Chat
google/gemma-4-31b-it Chat

You can also enter any custom OpenAI-compatible model ID.

Using Local Ollama

To use a local Ollama instance, set the environment variable and configure the endpoint:

set OLLAMA_ORIGINS=*
ollama serve

Then in the extension settings, set:

  • API Endpoint: http://localhost:11434/v1
  • Model: your Ollama model name, such as llama3, qwen2.5, or mistral
  • API Key: leave empty for local endpoints that do not require a key

Remote non-local HTTP endpoints are intentionally blocked; use HTTPS for hosted providers.

Tech Stack

  • Manifest V3
  • Vanilla JavaScript
  • OpenAI-compatible Chat Completions API

Development

git clone https://github.com/OpenTester007/Chat-with-KB.git
cd Chat-with-KB
# Load unpacked in edge://extensions/ (Developer mode)

Edit popup.js, popup.html, background.js, or style.css, then reload the extension from edge://extensions/.

Basic checks:

node --check popup.js
node --check background.js

Project Structure

manifest.json          # Extension manifest (MV3)
background.js          # Service worker and API request handling
popup.html             # Main popup UI
popup.js               # Popup UI logic
style.css              # Styles
screenshots/           # Screenshots for documentation
16.png / 32.png        # Extension icons
48.png / 128.png       # Extension icons
LICENSE                # MIT License
CONTRIBUTING.md        # Contribution guidelines
CODE_OF_CONDUCT.md     # Community code of conduct
ROADMAP.md             # Planned features
CHANGELOG.md           # Release history

Architecture & Security Design

This project is built under strict compliance with modern Manifest V3 extension standards, focusing heavily on safety, efficiency, and compliance:

  • Strict Content Security Policy (CSP): Completely complies with Chrome/Edge Web Store requirements. Zero usage of unsafe-eval or inline styles. All styles and logic reside in static .css and .js files.
  • XSS Prevention: User and AI outputs are rendered strictly using safe DOM APIs (e.g. textContent and innerText) to completely mitigate cross-site scripting (XSS) risks.
  • Non-Blocking Background Worker: Network requests and LLM streams run in background.js (Service Worker) using runtime message ports. The extension popup UI can be closed or switched to other tabs while tasks execute seamlessly in the background.
  • Test Key Distribution: The demo API key is intentionally public for frictionless onboarding. It is fetched remotely over HTTPS, with a local Base64-encoded fallback so new users can test immediately even without network access.

OpenAI Codex for OSS Program

This repository is submitted to the OpenAI Codex/API for Open Source Software program.

As the sole maintainer, I am responsible for the full lifecycle of this project: triaging issues, reviewing pull requests, managing releases, maintaining the CHANGELOG, and publishing updates to the Microsoft Edge Add-ons store.

Access to OpenAI Codex would help me sustain this work by:

  1. Reviewing community PRs faster — catching MV3 CSP, security, and cross-browser compatibility issues in code reviews.
  2. Improving documentation and issue responses — generating clearer explanations for bug reports and feature requests.
  3. Automating release workflows — drafting changelogs, release notes, and validation scripts for browser extension packaging.
  4. Shipping higher-quality releases — using AI-assisted refactoring and testing to reduce regressions across browser versions.

The "Import Test Key" feature is intentionally designed as a public demo key. It is not a leaked credential; it is a core product decision to let anyone test the extension immediately without registering for an API key.

All contributions and documentation comply with the MIT license.

Project Maintenance

This project follows a transparent, single-maintainer workflow:

  • Issues: All bug reports and feature requests are tracked in GitHub Issues and triaged regularly.
  • Pull Requests: Every change is reviewed, tested locally, and merged into main with a clear commit message.
  • Releases: Versions follow semantic versioning; each release is documented in CHANGELOG.md and published as a GitHub Release.
  • Store Updates: Final packages are uploaded to the Edge Add-ons store for public distribution.

Privacy

Settings, chat history, and translation history are stored locally with the browser storage API. Text entered by the user is sent to the configured API provider for processing.

License

MIT, see LICENSE.