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:
- Command+K Spotlight: Instantly accessible prompt modal from any page, rendered in isolated Shadow DOM
- Prompt Template Library: Reusable prompts with dynamic variable slots (
{selected_text},{page_title},{tone}) - Universal Text Injection: AI output is injected directly into the active text field — whether it's a
<textarea>,contenteditablediv, 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:
- Tab context-switching: Users constantly copy-paste text between separate ChatGPT browser tabs and their target web apps — losing flow state with every switch
- Scattered prompt templates: Custom system instructions and frequent prompts scattered across disconnected Notion pages, Slack messages, and sticky notes
- 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
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}→ readswindow.getSelection().toString()from the active tab{page_title}→ readsdocument.title{url}→ readswindow.location.href{clipboard}→ reads clipboard vianavigator.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 Type | Injection Strategy |
|---|---|
<textarea> | Direct element.value assignment + InputEvent dispatch |
<input type="text"> | Direct element.value + change event dispatch |
contenteditable div | document.execCommand('insertText') or Range API insertion |
| Draft.js / Quill | Synthetic beforeinput event dispatch at cursor position |
| CodeMirror 5/6 | editor.getDoc().replaceSelection() via Main World injection |
| Monaco Editor | editor.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
| Layer | Stack |
|---|---|
| Extension | Manifest V3, Content Script, Service Worker |
| Spotlight UI | React 18, Shadow DOM, Tailwind CSS |
| Prompt Storage | chrome.storage.sync (cross-device) |
| AI Engine | OpenAI GPT-4o streaming completions |
| Text Injection | DOM Range API, execCommand, Main World injection |
| Keyboard Shortcut | chrome.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 Metric | Manual Operational Baseline | Automated ChatCPU Pipeline | Measured Impact |
|---|---|---|---|
| Cycle Latency | 3–15 minutes per task | Sub-500ms automated execution | 95%+ latency reduction |
| Throughput Capacity | 20–50 transactions / day | 5,000+ operations / session | 100x scale enhancement |
| Error & Drop Rate | 8–12% human data entry error | < 0.1% deterministic parser accuracy | 99% accuracy rate |
| Operating Infrastructure | Recurring third-party SaaS fees | Zero-infrastructure client runtime | 100% cost reduction |
Frequently Asked Questions
QHow 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.
QCan 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.
QCan 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.
QHow 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).
