Skip to content

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nghien AI — Auto Comment

AI-powered Chrome extension that generates comments and replies on Facebook group posts using Claude API. Operates through a Side Panel alongside the Facebook tab.

Quick Start

1. Load the extension in Chrome

  1. Open chrome://extensions/
  2. Enable Developer mode (top-right toggle)
  3. Click Load unpacked
  4. Select this folder

2. Configure your API

  1. Click the extension icon to open the Side Panel
  2. Click the gear icon (top-right) to open Settings
  3. Fill in:
    • API Key: Your API key from any Claude-compatible provider (Anthropic, OpenRouter, etc.)
    • API Base URL: The API endpoint, e.g. https://api.anthropic.com/v1
    • Model: The Claude model name, e.g. claude-sonnet-4-20250514
    • Group URL: The Facebook group to target, e.g. https://www.facebook.com/groups/aiartworksvn
  4. Click Done to save

3. Use it

  1. Open the Facebook group in a Chrome tab
  2. Open the Side Panel (click extension icon)
  3. Click Scan Group Posts to find posts
  4. Click a post to navigate to its permalink and load all comments
  5. Click Generate to get AI-suggested comments
  6. Pick a suggestion (or edit), then click Post Comment
  7. For replies: find a comment, click Generate Reply, pick/edit, click Reply

Architecture

┌──────────────┐     chrome.runtime     ┌─────────────────┐
│  Side Panel  │ ◄──── messages ──────► │ Service Worker   │
│  panel.html  │                        │ service-worker.js│
│  panel.js    │                        │   ├─ claude-api  │
│  panel.css   │                        │   ├─ storage     │
└──────────────┘                        │   └─ cooldown    │
                                        └───────┬─────────┘
                                                │ chrome.tabs
                                                │ .sendMessage
                                        ┌───────▼─────────┐
                                        │  Content Script  │
                                        │  content.js      │
                                        │   ├─ feed scanner│
                                        │   ├─ permalink   │
                                        │   ├─ poster      │
                                        │   └─ selectors   │
                                        └─────────────────┘

Files

Path Purpose
manifest.json Chrome extension manifest (Manifest V3)
background/service-worker.js Message router, tab navigation, AI dispatch
background/claude-api.js API wrapper using Anthropic Messages format
background/storage.js Chrome storage helpers (config + state)
background/cooldown.js Rate limiting (cooldown disabled by default)
content/content.js Single content script: feed scanner, permalink scanner, comment poster
sidepanel/panel.html Side panel UI structure
sidepanel/panel.css Apple OS-inspired theme
sidepanel/panel.js Side panel logic (views, settings, AI actions)
icons/ Extension icons (16, 48, 128px)

Workflow

  1. Feed scan: Extension auto-scrolls the Facebook group feed, collects posts with text, author, permalink, and engagement stats
  2. Post detail: Navigates to a post's permalink URL, expands all comments and replies, extracts the full comment tree
  3. AI generation: Sends post + comment context to the configured API endpoint, returns 2 suggestions
  4. Posting: Simulates human typing (configurable speed, random typos) into Facebook textboxes, submits with Enter

Anti-Detection

  • Typing simulation: 60–180ms per character using document.execCommand('insertText')
  • Random typos: 3% chance of mistype → backspace → correct
  • Random pauses: 5% chance of 400–800ms pause; longer after punctuation
  • Configurable settings in the Side Panel

API Compatibility

The extension uses the Anthropic Messages API format (POST /v1/messages). It works with any provider that exposes a compatible endpoint:

Provider API Base URL
Anthropic (official) https://api.anthropic.com/v1
OpenRouter https://openrouter.ai/api/v1
Any Claude-compatible proxy Your provider's URL

Note: The API format is Anthropic-specific (system prompt, messages array, anthropic-version header). It is not compatible with OpenAI Chat Completions format. Make sure your provider supports the Anthropic Messages API.

Settings Reference

Setting Default Description
API Key (empty) Your API key
API Base URL (empty) API endpoint (must be Anthropic Messages-compatible)
Model claude-sonnet-4-6 Claude model name
Group URL (empty) Facebook group to target
System Prompt (see code) AI personality instructions
Daily Limit 20 Max comments per day
Min Delay 3 min Minimum delay between comments
Simulate Typing On Human-like typing simulation
Random Typos On Occasional typos with correction
Random Skip % 35% Posts to skip for natural behavior

Permissions

  • sidePanel — Chrome Side Panel API
  • storage — Save config and state
  • tabs / scripting — Content script injection, tab navigation
  • webNavigation — SPA URL change detection
  • *://www.facebook.com/* — Facebook page access

Notes for AI Agents

  • The content script is a single file (content/content.js) that survives SPA navigation. No re-injection needed.
  • Page type detection checks both URL regex and DOM ([role="feed"] existence).
  • Facebook is a React SPA — window persists across navigations. A __NGHIEN_AI_V4 guard prevents double-initialization.
  • The feed scanner uses a slot-based approach: iterates [role="feed"] children that contain permalink links, rather than depending on [role="article"] elements.
  • All DOM interaction follows ACTION → WAIT → VERIFY pattern.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages