IG AI Sorter
Case study — 04


01 — The problem
Instagram gives you collections, but filing hundreds of saved posts into them is a manual job: open the post, hover the bookmark, find the collection, click it, close it. That is fine for ten saves and hopeless for a library.
IG AI Sorter does the filing. A vision model looks at each saved thumbnail, decides what it is, and the extension puts it in the matching collection.
02 — Three phases, one popup
Collection stays deliberately manual: a content script records every saved-post tile you scroll past, and nothing is auto-scrolled or auto-navigated, so if you stop scrolling, it stops collecting. A badge on the toolbar shows the count while you work.
Classification sends each thumbnail to a vision model with a fixed system prompt that forces JSON in the shape {“category”, “confidence”}. It runs three requests at a time with retries and exponential backoff, and treats a per-minute rate limit as a scheduling problem: the refused post is re-queued and the whole run waits out a shared cool-down instead of failing posts.
Sorting opens each classified post in its own tab, picks the collection, and closes the tab. Posts already written are skipped, so a run can be stopped and resumed at any point.
03 — Writing back without a password
The extension never asks for, reads or transmits an Instagram password. It rides on the session your browser already has, and only the thumbnails and your category list ever reach the model provider.
The hard part is that the collections picker is a CSS :hover popover — something no scripted event can honestly produce, because React derives enter and leave from the event stream. So the writer does not fake a hover: it finds the popover, which Instagram keeps mounted but hidden, sets inline !important styles on whatever is hiding it, clicks the row, then puts every property back exactly as a real pointer leaving would have.
After the click it reads the selection back — input.checked, then aria-checked, then a checkmark icon — and a click whose result cannot be read is reported as unconfirmed rather than counted as sorted.
04 — Built for a page that moves
Instagram regenerates its obfuscated class names on every deploy, so no selector in the project uses a class name. Everything keys off ARIA labels, roles, visible text and href shape, each lookup with an ordered list of fallbacks and a timeout.
When several posts in a row fail the same way, a circuit breaker stops the run and explains instead of grinding through the rest of the library. A dry run performs the whole sort without clicking anything, a per-post audit records which element was clicked and what the picker actually contained, and Diagnose prints the state of the pipeline as a readable report.
Features
- Three phases from one popup: collect by scrolling, classify with a vision model, sort into collections
- Passive collection — records only tiles you actually scroll past, with no auto-scroll or navigation
- Vision model answers in strict JSON (category + confidence), with 3 concurrent requests, retries and backoff
- Free-tier rate limits are paced, not failed: a per-minute 429 re-queues the post behind a shared cool-down
- Writes back through your own Instagram session by revealing the mounted-but-hidden Collections popover
- Paced and resumable — 2–4 s per post, a pause after every 20, and confirmed vs unconfirmed writes reported separately
- Dry run, a per-post audit and a Diagnose report that names the step that failed
- Bring your own model: DeepSeek, Gemini's free tier, OpenRouter, a local gateway, or fully offline Ollama