Skip to content

About

A bilingual Chrome extension that provides real-time chess board detection, structural positioning evaluation, and dynamic auto-highlighting. Built as an educational tool for analyzing chess positions directly in the browser.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

ChessCube Assistant

A bilingual Chrome extension that provides real-time chess board detection, structural positioning evaluation, and dynamic auto-highlighting. Built as an educational tool for analyzing chess positions directly in the browser.

✨ Features

  • Universal Board Detection: Dynamically reads DOM states and is compatible with modern web components like cg-board, chess-board, and generic piece layouts.
  • Real-Time Observation: Uses a debounced MutationObserver to automatically track piece movements without requiring manual page refreshes.
  • Smart Auto-Highlighting: Generates a synchronized, detached DOM overlay to visually indicate the engine's suggested move directly on the board, ensuring it doesn't interfere with the host website's native drag-and-drop mechanics.
  • Animated Tug-of-War UI: Features a dynamic, animated progress bar that visualizes your win chance based on the current evaluation.
  • Deep Customization: Includes a settings panel to toggle Dark/Bright modes, upload custom app backgrounds, add custom corner stickers/GIFs to the highlighted squares, and customize the highlight colors.
  • Bilingual Interface: Fully supports both English and Kurdish (Sorani), dynamically adjusting text direction (LTR/RTL) and typography using the Vazirmatn font.

🚀 Installation

  1. Clone this repository or download the source code as a ZIP file and extract it.
  2. Open Google Chrome and navigate to chrome://extensions/.
  3. Enable Developer mode (the toggle located in the top right corner).
  4. Click Load unpacked in the top left.
  5. Select the extracted chesscube-extension directory.

🎮 How to Use

  1. Navigate to a webpage containing a supported chess board.
  2. Click the ChessCube Assistant icon in your Chrome toolbar to open the side panel.
  3. The extension will automatically detect the board, determine your playing color, parse the position, and fetch the evaluation.
  4. The best move will be automatically highlighted on the board.
  5. Click the ⚙️ (Gear Icon) in the side panel header to open the customizations menu and personalize your UI.
  6. If the board state gets out of sync or you navigate to a new game, click the ↻ (Rescan) icon in the side panel header to manually trigger a fresh DOM scan and clear existing highlights.

🧠 How It Works (Architecture)

ChessCube operates using a decoupled architecture, separating DOM observation, API communication, and state management into specific extension components.

1. Service Worker (background.js)

The background script acts as the central message router and state manager.

  • Injection Logic: To save memory, it safely manages the programmatic injection of the content script into the active tab only when the user opens the side panel.
  • Event Routing: It listens for board state changes from the content script, relays them to the side panel, and routes highlight commands and user preferences back to the active webpage.

2. Content Script (content-universal.js)

This script handles all direct interaction with the host webpage's DOM.

  • Board Parsing Logic: It scans for standard chess board elements and extracts piece positions based on CSS classes and 2D transform coordinates. It then reverse-engineers the board state into a standard FEN (Forsyth–Edwards Notation) string.
  • Highlight Overlay Logic: Instead of injecting elements directly into complex virtual DOMs, it calculates the getBoundingClientRect() of the board. It then creates a detached absolute overlay fixed to the document body, mapping standard algebraic notation to X/Y percentages. It recalculates these positions automatically on window resize or scroll.

3. Engine Integration & UI (sidepanel.js & sidepanel.html)

The side panel serves as the user interface and the external communicator.

  • Evaluation Logic: It receives the valid FEN string from the background worker and sends an asynchronous payload to a public Stockfish 16 API (chess-api.com/v1).
  • Data Parsing: It processes the returned JSON to extract centipawn evaluations, calculate win-chance percentages, and format the principal variation (PV) lines.
  • Error Handling: It strictly validates structural anomalies to prevent math errors or crashes if an illegal FEN is accidentally generated during piece animations.

About

A bilingual Chrome extension that provides real-time chess board detection, structural positioning evaluation, and dynamic auto-highlighting. Built as an educational tool for analyzing chess positions directly in the browser.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages