UGC Extension — UGC video prompt builder
A Chrome extension (MV3, Side Panel) + full-stack CMS that chains 3 jobs into one pipeline: scrape a product, build a video prompt (BYOK LLM), then feed it automatically via CDP into an AI video site that has no public API · Prompts and options are edited in the backoffice without shipping a new extension

A Chrome extension (MV3, Side Panel) that works as one pipeline: pull product data from the page (passive scrape) → build a system prompt from the CMS and call the user's own LLM (BYOK) → type the prompt, attach images and press generate on an AI video site with no public API, automatically via CDP · The back end is a NestJS API + CMS where prompts and options can be edited without shipping a new extension
The problem
Why does making a UGC product review video with AI still take a dozen steps of copying, pasting and typing by hand?

The best-quality AI video tool for Thai creators has no public API. You go to the site, type the prompt, upload reference images and press generate, one scene at a time. Before that you still have to find product info and write a good English prompt, for every product and every scene. It takes a huge amount of time and the results aren't consistent.
Product info typed in by hand every time
Name, price and images are scattered across the page. Copy one field at a time, repeat for every product · Many e-commerce sites also have anti-bot protection that blocks automated scraping
Writing a good video prompt isn't easy
Video prompts that look good need to be in English, with framing, lighting and camera angles covered. Content creators shouldn't have to write them for every scene and every mode.
The AI video site has no API to connect to
The best-quality option can only be driven through its web page: type the prompt, upload images, press generate, press + to add a scene, by hand every time. There's no way to send a request directly.
Every prompt or option tweak meant a new release
With prompts and options (themes, selling angles, effects) baked into the extension code, every prompt tweak meant building and distributing a new extension. Slow and inflexible.
Holding LLM keys for users is a liability
If the system holds AI keys for users, we carry the cost and quota and the risk of keys leaking on our side. A burden I didn't want from day one.
The solution
Have the extension chain 3 jobs into one pipeline (scrape → generate prompt → feed the AI video site), so all that's left is "pick, then press Auto"

Passive scraping that gets past anti-bot
The content script runs on the page the user opened themselves, pulling the name, price and images from the Shopee API, JSON-LD or __NEXT_DATA__ without triggering anti-bot systems that block automated navigation
Prompts built from the CMS + the user's own LLM
The system prompt is assembled from Tab.systemPrompt + Option.promptFragment pulled from the back end, then sent to the user's own LLM (BYOK) → an editable English prompt card plus a Thai script
A flow executor via CDP
Uses chrome.debugger to type the prompt as trusted keystrokes, attach reference images via DataTransfer, and press generate and add-scene, feeding work into an AI video site that has no API, automatically
Config-driven: edit in the CMS, no new release
All prompts, options and cover images live in the back end and are edited in the backoffice CMS → the extension fetches GET /config and renders it. Prompts can be tuned instantly without rebuilding the extension.
BYOK: no one else's keys held
Users enter their own LLM key, stored in that machine's chrome.storage.local and never sent to the back end. No proxy, no cost or quota to carry, no risk of keys leaking on our side.
How it works, in 4 steps
From opening a product page to the video starting to generate on the AI site


Pull product data
Open a product page as usual → press "Pull data" → passive scrape of name, price and images
Pick a mode + options
Choose presenter / product / short drama / viral, plus theme, selling angle and effects from the config
The LLM builds the prompt
The user's key → an editable English prompt card plus a Thai script
Auto → AI video site
CDP types the prompt, attaches images, presses generate and adds the next scene
Tech Stack & Architecture
3-tier: clients (extension + CMS) talk only through the NestJS API, never to the DB directly

MV3 + Side Panel keeps the UI pinned next to the target page (unlike a popup that closes when you click away) · chrome.debugger (CDP) is the only way to send trusted input into a site with no API · NestJS + Prisma + PostgreSQL gives the back end a clear module/guard/DI structure and safe migrations · Config-driven moves prompts and options into the CMS, editable without shipping a new extension · Vanilla JS in the extension: no build step, load it unpacked and go
What I built: 8 core capabilities
The full loop, from pulling product data to feeding work into the AI video site

Passive Product Scraper
Pulls name, price and images from the page the user opened: Shopee API, JSON-LD, __NEXT_DATA__, dom-scan · gets past anti-bot · unsupported sites = fill in by hand (editable)
Image Gatherer + Picker
Collects all images on the page and lets you pick reference images to attach on the AI video site as each scene's reference
Config-driven Prompt Engine
Builds the system prompt from Tab.systemPrompt + Option.promptFragment, replacing {{fieldKey}} with the chosen options and entered values
Multi-provider LLM (BYOK)
OpenAI / DeepSeek / Gemini / Qwen through one OpenAI-compatible endpoint + JSON mode. Adding a provider = adding one row to a table
Flow Executor (CDP)
Types the prompt (trusted keystrokes), attaches reference images (DataTransfer), presses generate and adds scenes, locating buttons and fields by text/role
Background Removal
Removes product image backgrounds with OpenAI image edit (falling back across several models) for a clean transparent PNG reference
Backoffice CMS
Prompts, options and cover images are editable at 3 levels (tab → field → option) with S3 cover uploads. Edit it and the extension follows, no release needed
Auth + Audit + Users
JWT + bcrypt (checked against the real DB, not env), an audit log of every mutation (who changed what), users CRUD + role guard
The side panel
Open it next to the target page → pull the product → get prompt cards → press Auto

Hacking the problems
6 problems I had to solve myself: browser automation quirks and full-stack product architecture

The target site ignored synthetic keystrokes
The prompt field is a rich-text editor (Lexical), and the generate button only enables after real human input. Events fired with plain JS went unnoticed by the editor, so the button stayed disabled.
chrome.debugger (CDP). Input.insertText + dispatchMouseEvent count as trusted input, just like a person typing · The center of each field or button is found by injecting a function into the page that measures getBoundingClientRect()E-commerce sites blocked scraping
Opening product URLs directly from automation usually gets blocked by a WAF or anti-bot, so no data comes through at all.
passive scrape. The content script runs on "the page the user opened themselves" (searched or clicked through the store as usual), so it doesn't trigger anti-bot systems that detect automated navigation · Separate adapters per site (Shopee API / generic JSON-LD)The target site's DOM was fragile and had decoy buttons
The target site uses random classes (sc-*) that change with every build, so fixed selectors can't locate anything · The "+" button (add source) and the generate button have similar labels, and clicking the wrong one breaks the flow
by-text/by-role instead of by class. Filter to buttons that are visible + enabled + whose text matches generate/create, then explicitly exclude the add button (if the right button isn't found, return null rather than falling back to some other button)Hardcoded prompts and options = a release for every tweak
Originally the prompts for all 4 modes and every option were baked into sidepanel.js, so each prompt tweak meant building and distributing a new extension.
GET /config and renders it · A config-fallback.js (auto-generated from the seed) keeps it working even when the back end is downHolding users' LLM keys = carrying the risk
If the back end stored AI keys for users, we'd carry the cost and quota, the risk of leaks, and need an extra proxy layer.
chrome.storage.local and never reach the back end · No LLM proxy, no cost to carry, and the risk of keys leaking on our side is gone entirelySupporting several LLM providers without bloating the code
Users might use OpenAI / DeepSeek / Gemini / Qwen. Writing a separate integration for each means duplicated code that's hard to maintain.
Deliberate design decisions
What I chose not to build matters as much as what I built

This extension is a "bridge", not a "factory". It speeds up scraping, building prompts and feeding work into the AI video site, but it stops at "press generate" · It doesn't edit the video (the user does), doesn't hold LLM keys, and doesn't touch the DB directly (API only). A clear scope from the start meant a direct implementation that's easy to maintain.
BYOK in every phase
Keys stay with the user only: not held, not proxied, no cost carried
Config-driven
Edit prompts and options from the CMS without shipping a new extension
Clients talk through the API
The extension and CMS never touch the DB directly: a clear structure with auth and audit under control
Stops at "press generate"
No video editing: a sharp scope, a small, focused tool
Knowledge domains that got stronger
5 areas where my skills actually moved up through this project

I learned the Side Panel lifecycle and event-driven service workers, and most deeply chrome.debugger (CDP): sending trusted mouse and keyboard events, injecting functions into the MAIN world to measure element positions, and driving a full flow on a site that has no API. Lesson: when there is no API, browser automation done properly is a bridge that actually works.
I designed NestJS (module/DI/guard) + Prisma + PostgreSQL + JWT/bcrypt + audit log + S3 upload, and a Next.js CMS that communicates only over REST. It showed me how auth, migrations, audit and media storage fit together as a system. Lesson: the rule "clients talk only through the API" lets the system control security and audit in one place.
I moved prompts, options and cover images from hardcode into the CMS, laid out a Tab → Field → Option data model that assembles into a prompt, and added a fallback strategy (bundled config when the back end is down). Lesson: things that change often (prompts) belong where they can be edited without a deploy.
I learned that a passive scrape gets past anti-bot because it runs on the page the user opened, that data can be pulled from several layers (API / JSON-LD / __NEXT_DATA__), and that buttons on a site whose classes keep changing can be located by text/role instead. Lesson: automation that survives change has to rely on what an element means, not its class name.
I used an OpenAI-compatible endpoint + JSON mode to cover several providers with one config table, designed two-layer prompt assembly (system template + fragment), and set BYOK as a constraint from the start. Lesson: deciding key ownership and provider abstraction on day one saves a huge rebuild later.
