惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
爱范儿
爱范儿
GbyAI
GbyAI
博客园 - 叶小钗
Last Week in AI
Last Week in AI
Jina AI
Jina AI
Microsoft Security Blog
Microsoft Security Blog
云风的 BLOG
云风的 BLOG
C
Check Point Blog
H
Help Net Security
P
Proofpoint News Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
大猫的无限游戏
大猫的无限游戏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
B
Blog RSS Feed
Y
Y Combinator Blog
U
Unit 42
T
Tailwind CSS Blog
MyScale Blog
MyScale Blog
N
Netflix TechBlog - Medium
S
SegmentFault 最新的问题
J
Java Code Geeks
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
I Built a Chrome Extension That Generates AI Replies for ...
Tanuj · 2026-05-24 · via DEV Community
Cover image for I Built a Chrome Extension That Generates AI Replies for LinkedIn, X and Threads — Here's What I Learned

Tanuj

Building Replygen started as a personal itch. As a solo SaaS founder, I needed to stay consistently active on LinkedIn, X, and Threads to drive organic distribution — but crafting thoughtful replies at scale was burning time I didn't have. So I built an AI engagement co-pilot that lives in your browser and suggests context-aware replies as you scroll your feed.

This post is a technical walkthrough of the key architecture decisions, the unexpected challenges, and the lessons that only come from shipping a real Chrome extension to production users.

The Core Architecture

The extension follows the standard content script + background service worker pattern:

  • Content script — injected into LinkedIn/X/Threads DOM. Handles UI injection (the suggestion overlay), reads post content via DOM selectors, sends data to the background worker via chrome.runtime.sendMessage
  • Background service worker — handles LLM API calls, manages auth tokens, persists preferences via chrome.storage.sync
  • Side panel — settings, tone configuration, usage stats

This is clean in theory. In practice, the DOM layer is where all the pain lives.

The DOM Fragility Problem

LinkedIn, X, and Threads update their frontend constantly. Selectors that worked last week break silently this week — no errors, just a blank suggestion box.

The solution we landed on:

const POST_SELECTORS = {
  linkedin: [
    '.feed-shared-update-v2__description',
    '.feed-shared-text',
    '[data-test-id="main-feed-activity-card"]'  // fallback
  ],
  twitter: [
    '[data-testid="tweetText"]',
    '.tweet-text'  // legacy fallback
  ],
  threads: [
    '._a9zs',
    '[class*="x1iorvi4"]'  // brittle, needs frequent updates
  ]
}

We run a selector health check on extension startup — if the primary selector returns null, it falls through to the next. When all fallbacks fail, the UI gracefully shows "Content unavailable" rather than throwing an error.

Prompt Design: Making Replies Sound Like You

The first version generated generic, professional replies. Users hated it. The fix was a three-layer prompt structure:

  1. Layer 1: Platform context
    "You are writing a LinkedIn comment. LinkedIn has a professional, insight-driven tone..."

  2. Layer 2: Post context
    "The post you are replying to says: [post_content]
    Thread context: [thread_context]"

  3. Layer 3: User tone profile
    "The user's writing style: [tone_descriptor]
    Examples of their recent comments: [sample_1], [sample_2]"

Constraints:

  • Under 280 chars for X replies
  • Never start with "Great post!" or similar filler
  • Always add a unique perspective, not just agreement text
  • The tone profile is built from the user's last 15–20 posts, summarized into a descriptor. This one change improved day-7 retention significantly.

Handling API Costs at Scale

Two optimizations that cut costs by ~40%:

1. Prompt caching — platform context and user tone profile are static between requests. Using Anthropic's prompt caching on these portions means you only pay full tokens for the dynamic post content.

2. Generation gating — only fire the API call when the user explicitly clicks "Generate Reply." Early versions pre-generated proactively and burned tokens on posts users never engaged with.

Auth Architecture

Users authenticate with Google OAuth for account management and cross-device sync. Platform sessions (LinkedIn, X, Threads) are never stored — the extension operates on whatever browser session is already active. Zero credential storage liability, zero OAuth integration work per platform.

The UX Insight That Changed Everything

Early version had a two-step flow: generate → confirm → post. Collapsed to a single-click post flow (with a 3-second undo toast) — this doubled daily active usage in the week after shipping.

Every extra click in a workflow tool is a reason to abandon the habit. Optimize ruthlessly for speed of the happy path.


If you're building something in the Chrome extension + AI space, happy to compare notes. Try the extension at replygen.app.