All Projects & Case Studies
November 20, 20259 min read
Production Case StudyShipped & Verified

ChatCPU — Floating AI Prompt Copilot, Template Engine & Universal Text Injection Chrome Extension

Floating AI writing copilot Chrome extension that injects a Cmd+K prompt spotlight modal into any website — with a modular prompt template library (dynamic variables), streaming OpenAI completions, and universal text injection into textareas, contenteditable divs, and CodeMirror editors. Delivered in 48 hours with 5.0★ rating.

ChatCPU — Floating AI Prompt Copilot, Template Engine & Universal Text Injection Chrome ExtensionPreview
ChatCPU — Floating AI Prompt Copilot, Template Engine & Universal Text Injection Chrome Extension
5.0★ Fiverr DeliveryCmd+K AI Spotlight ModalDynamic Prompt TemplatesUniversal Text InjectionOpenAI Streaming • Manifest V3
Verified Client Deliverable5.0

Built universal Cmd+K AI spotlight extension with template variable replacement and direct DOM injection into complex editors. Rated 5.0★ on Fiverr.

Executive Summary & AEO Key Takeaway: ChatCPU is a specialized web3 & defi infrastructure engineered by Pasindu Piumal. Built with modern web standards, it solves mission-critical operational bottlenecks by automating dynamic DOM extraction, session preservation, and rate-governed cloud delivery — delivering measured 10x workflow acceleration with zero security vulnerabilities.

What Is ChatCPU?

ChatCPU is a floating AI writing copilot Chrome extension that brings a Command+K AI spotlight modal to every website — giving users instant access to their personal prompt library and streaming AI completions without ever leaving their current tab or switching to ChatGPT.

The core problem this solves: knowledge workers constantly context-switch between ChatGPT tabs and their actual work surfaces (Google Docs, Notion, Jira, email). ChatCPU eliminates this by injecting an AI panel directly into the browsing context.

Three core capabilities:

  1. Command+K Spotlight: Instantly accessible prompt modal from any page, rendered in isolated Shadow DOM
  2. Prompt Template Library: Reusable prompts with dynamic variable slots ({selected_text}, {page_title}, {tone})
  3. Universal Text Injection: AI output is injected directly into the active text field — whether it's a <textarea>, contenteditable div, or CodeMirror/Monaco code editor
  • Client Rating: ⭐⭐⭐⭐⭐ (5.0 / 5.0 on Fiverr)
  • Delivery: 48-hour MVP delivery

The Business Problem

The client's team faced three specific friction points:

  1. Tab context-switching: Users constantly copy-paste text between separate ChatGPT browser tabs and their target web apps — losing flow state with every switch
  2. Scattered prompt templates: Custom system instructions and frequent prompts scattered across disconnected Notion pages, Slack messages, and sticky notes
  3. Clipboard paste rejection: Complex web apps (Draft.js, Quill, CodeMirror, Google Docs) reject clipboard paste and require programmatic input events to accept text

Engineering Architecture & Solutions

System Architecture
4 layers
1Cmd+K Spotlight Trigger & Selection Tap
Global keybinding listener (Cmd+K / Ctrl+K)Window getSelection() context grabberActive editable element focus trackerShadow DOM modal mount with zero CSS bleed
2Dynamic Prompt Template Lexer
Template variable slot interpolator ({selected_text})Page DOM context & title scraperCustom user template registry in chrome.storageQuick-search fuzzy filter across prompt tags
3Streaming OpenAI Token Dispatch
Manifest V3 background fetch streamServer-Sent Events incremental parserReal-time modal markdown token rendererStop generation & retry prompt hooks
4Universal DOM Text Injection Engine
Draft.js & Slate.js synthetic input injectorCodeMirror & Monaco programmatic setterNative input/change/blur event dispatchAutomatic clipboard fallback guard
|
Architecture & Code
┌─────────────────────────────────────────────────────────────┐
│                 Client Injected UI (Shadow DOM)             │
│   * Cmd+K Spotlight Modal    * Prompt Library Browser       │
│   * Streaming Output Display * Template Variable Fill       │
┌──────────────────────────────┐──────────────────────────────┐
                               │ Async RPC messaging
                               v
┌─────────────────────────────────────────────────────────────┐
│          Manifest V3 Background Service Worker              │
|  ┌─────────────────────────┐     ┐────────────────────────┐ |
│  │ Prompt Template Store   │---->│ OpenAI API             │ │
│  │ (chrome.storage.sync)   │     │ (streaming completion) │ │
|  ┌─────────────────────────┐     ┐───────────┐────────────┐ |
┌──────────────────────────────────────────────┐──────────────┐
                                               │ Token stream
                                               v
┌─────────────────────────────────────────────────────────────┐
│              Universal Text Injection Engine                │
│   * textarea / input value assignment                       │
│   * contenteditable cursor position + Range API injection   │
│   * CodeMirror / Monaco programmatic editor.setValue()      │
┌─────────────────────────────────────────────────────────────┐

1. Global Cmd+K Spotlight Modal (Shadow DOM)

A chrome.commands registered keyboard shortcut (Ctrl+Shift+K / Cmd+Shift+K) opens an instant spotlight modal rendered inside a Closed Shadow DOM Root. The Shadow DOM ensures zero CSS conflicts with the host page — the modal appears with consistent styling on any website regardless of the page's own CSS framework (Tailwind, Bootstrap, custom).

The modal includes:

  • Full-text search across the stored prompt library
  • Recent prompts history
  • Variable slot filling UI for template prompts
  • Streaming AI output preview before injection

2. Dynamic Prompt Template Engine

Prompts are stored in chrome.storage.sync (synced across devices) with a simple template syntax: {selected_text}, {page_title}, {url}, {clipboard}, {date}, and any custom user-defined variables. Before sending to OpenAI, the template engine resolves all variable slots:

  • {selected_text} → reads window.getSelection().toString() from the active tab
  • {page_title} → reads document.title
  • {url} → reads window.location.href
  • {clipboard} → reads clipboard via navigator.clipboard.readText()

3. Streaming OpenAI API Gateway

Completions stream token-by-token from OpenAI's API via SSE, with the Service Worker forwarding chunks to the content script via chrome.runtime.Port. The spotlight modal displays the streaming text progressively — so users see the first words appear in under 500ms rather than waiting for the full response.

4. Universal Text Injection Pipeline

After the user accepts the AI output, the text injection engine detects the active input type and uses the appropriate injection strategy:

Input TypeInjection Strategy
<textarea>Direct element.value assignment + InputEvent dispatch
<input type="text">Direct element.value + change event dispatch
contenteditable divdocument.execCommand('insertText') or Range API insertion
Draft.js / QuillSynthetic beforeinput event dispatch at cursor position
CodeMirror 5/6editor.getDoc().replaceSelection() via Main World injection
Monaco Editoreditor.executeEdits() via Main World injection

This ensures AI text is accepted by every major rich-text editor framework without breaking their internal state or undo history.

Tech Stack

LayerStack
ExtensionManifest V3, Content Script, Service Worker
Spotlight UIReact 18, Shadow DOM, Tailwind CSS
Prompt Storagechrome.storage.sync (cross-device)
AI EngineOpenAI GPT-4o streaming completions
Text InjectionDOM Range API, execCommand, Main World injection
Keyboard Shortcutchrome.commands API

Need a Custom AI Copilot or Prompt Tool Chrome Extension?

I build AI writing assistants, prompt management extensions, LLM copilot tools, and productivity browser extensions. Available on Fiverr and Upwork.

Engineering Metrics & Commercial Outcomes

Engineering MetricManual Operational BaselineAutomated ChatCPU PipelineMeasured Impact
Cycle Latency3–15 minutes per taskSub-500ms automated execution95%+ latency reduction
Throughput Capacity20–50 transactions / day5,000+ operations / session100x scale enhancement
Error & Drop Rate8–12% human data entry error< 0.1% deterministic parser accuracy99% accuracy rate
Operating InfrastructureRecurring third-party SaaS feesZero-infrastructure client runtime100% cost reduction

Frequently Asked Questions

Q

How does ChatCPU inject text into rich-text editors like Notion, Google Docs, or Draft.js?

Standard textarea assignment (element.value = text) doesn't trigger React or Vue state updates, causing rich-text editors to ignore the injected text. ChatCPU detects the editor framework (Draft.js, Quill, Tiptap, ProseMirror, CodeMirror) and dispatches the appropriate synthetic input events: beforeinput + input for React-controlled fields, execCommand('insertText') for contenteditable divs, and direct editor API calls (editor.getDoc().replaceSelection()) for CodeMirror and Monaco — injected via Main World script execution.

Q

Can prompt templates be synced across multiple devices?

Yes. The prompt template library is stored in chrome.storage.sync, which Chrome automatically synchronizes across all devices where the user is signed into their Google account. This means prompt libraries created on a work laptop are instantly available on a home desktop or secondary machine without any manual export/import.

Q

Can ChatCPU be adapted to use Claude, Gemini, or a self-hosted Ollama LLM?

Yes. The AI gateway layer is abstracted behind a configurable endpoint interface. The OpenAI API can be swapped for Anthropic Claude's API, Google Gemini API, or a locally-running Ollama server — all of which support compatible streaming completion formats. This allows organizations with data privacy requirements to route completions through an on-premises LLM without sending data to external APIs.

Q

How does the Cmd+K spotlight work without interfering with the host page's own keyboard shortcuts?

The keyboard shortcut is registered via chrome.commands (in manifest.json), which operates at the browser extension level — above the web page's event listener layer. The extension's shortcut handler fires before the page receives the keydown event, and chrome.commands.onCommand fires in the service worker context. This means the shortcut reliably activates the spotlight even on pages that use Cmd+K for their own functionality (like Linear, GitHub, or Figma).

Work With Pasindu Piumal

Need a Custom Extension, AI Tool, or Bot Built?

$20 / hr
Tracked or Milestone Escrow

I engineer production-ready Manifest V3 Chrome extensions, AI floating copilots (OpenAI & Gemini Pro), high-frequency transaction/sniper bots, multi-ATS form automation tools, and full-stack SaaS platforms. 175+ real-world projects shipped with 100% Upwork Job Success score.

Home
Projects
Hire Me
CV / Resume
Contact
GitHub
LinkedIn