Insta Joker UA
How the bot works · build 20 · November 2026

Insta Joker UA

A Chrome extension that answers Віталій's Instagram DMs in casual, funny Ukrainian. It writes in his voice, and the AI runs on his own Mac mini through Ollama.

Chrome MV3 extension MamayLM 12B · replies qwen2.5vl 7B · photos 713 of my old replies 60 s pause per chat 20 replies / hour max
The parts

What runs where

Chrome holds the extension code. Ollama holds the two AI models, which stay loaded in memory all the time. The internet is used only to look up facts like weather or exchange rates.

The Chrome extension talks to Ollama models on the Mac mini and to internet APIs, and the watchdog keeps Chrome open Internet APIs Weather · NBU · Wikipedia · Tavily CHROME EXTENSION content.js Reads chats, types replies background.js Prompt, models, cleanup tools.js Looks up facts Popup Settings and log memory.js Finds my similar replies Watchdog Reopens Chrome if closed OLLAMA ON MAC MINI MamayLM 12B Writes the reply · 8.3 GB qwen2.5vl 7B Describes photos · 7.6 GB
Extension code AI model in Ollama Internet
One message, start to finish

How a reply is made

  1. A new message is spotted

    content.js

    Every 5 seconds the bot reads the open chat. The patrol also opens unread chats from the inbox list by itself. A chat that still looks unread after a click is skipped for 3 minutes, so it can't block the others.

  2. Should I answer?

    content.js

    The bot only answers when the last message is the friend's, it's new, and you aren't typing yourself. Each chat gets at most one reply every 60 seconds. A message that arrives during that pause waits and gets answered once the pause is over. A chat seen for the first time after a restart is only remembered, not answered.

  3. Look at photos and stickers

    background.js → qwen2.5vl

    A friend's picture is downloaded, shrunk to 768 px and described in one Ukrainian sentence, for example «[фото: чоловік у жовтій куртці]». That takes 2–15 seconds. If the friend sent only pictures the bot couldn't make out, it stays silent.

  4. Build the prompt

    background.js + memory.js + tools.js

    The model gets: the style rules, the date and time, the last 14 messages of the chat, the word list (for example «гаразд → норм»), and about 6 of your old replies to similar messages plus 3 recent ones with this friend. For a question about weather, rates or the news, the facts are looked up first.

  5. MamayLM writes the reply

    Ollama

    A Ukrainian-tuned Gemma 3 model writes one short reply in your voice, in masculine forms, usually within 5–10 seconds. If Ollama fails, a ready-made phrase is used instead.

  6. Clean up and send

    background.js → content.js

    The text is checked for the model's usual mistakes, then the bot waits 1.5–4 seconds to look human, types the reply and presses Enter.

Your voice

How it learns to sound like you

my-replies.json

Your old chats

learn/build_pairs.py read your Instagram export and saved 713 pairs of "what a friend wrote → what you answered" from 78 chats.

  • Only messages from before 1 November 2026, so the bot's own replies aren't included
  • Group chats and swearing are left out
  • Answers more than 6 hours later are skipped
memory.js

Picking examples

For each new message the bot finds the old exchanges with the most similar wording (it compares letter patterns), and gives a bonus to the same friend. The model copies your manner, length and emoji. The rules tell it not to copy text word for word or take facts from these examples.

Last safety net

What the cleanup fixes

Local models repeat the same habits, so every reply passes through fixed rules before it's sent.

[фото або стікер] Ну і технології зараз! 😅 → Технології зараз! 😅 Віталій: Щойно прокинувся → Щойно прокинувся Гаразд, домовились → Норм, домовились дякую тебе → дякую тобі
RuleWhy
Remove a leading «Ну», «Ну і», «Ну, …»The model copied its own openers and every reply started the same way
Remove «[фото…]», «[відео]», «[посилання…]»Those markers are how the bot shows pictures to the model, and it sometimes copied them
Remove «Віталій:», «Я:» at the startMamayLM sometimes writes the reply like a script line
Word list from the popupRussianisms and words you don't use: «ладно», «гаразд» → «норм», «щас» → «зараз»
Grammar fixes«дякую тебе» → «дякую тобі», «на протязі» → «протягом»
Staying alive

Keeping it running while you're away

watchdog.sh · every 5 min

Watchdog

A macOS background job checks Chrome every 5 minutes. If Chrome is missing on two checks in a row (for example after an overnight macOS update), it reopens Chrome on the Instagram inbox. Creating the file .watchdog-off pauses it.

Chrome flags

Works with the screen locked

Chrome starts with flags that stop it from slowing down hidden tabs. The Instagram tab is protected from Memory Saver, and the Mac is kept from sleeping while the bot is on.

BUILD number

Picks up new code

The page part and the background part both carry a build number. When they differ after an update, the background reloads itself (log: «🔄 Оновлюю фон: 19 → 20»).

Limits

Doesn't overdo it

  • One reply per chat per 60 seconds
  • At most 20 replies an hour overall
  • Optional list of allowed chats
  • Auto-send can be turned off so it only fills in the reply
Reading the log

What the log lines mean

LineMeaning
Патруль: відкриваю…The patrol opened an unread chat
[бачу] чат=…What the bot read in the chat: the last 3 messages, «моє» = yours, «їхнє» = the friend's
Пауза для «…»A new message came during the 60 s pause; it will be answered after
👁️ …What qwen2.5vl saw in a photo, and how long it took
«chat»: message → replyThe reply that was written
✅ Надіслано (Enter)The reply was sent
…не відповідаюOnly a picture the bot couldn't make out, so it stayed silent
Ollama помилка…The model failed; a ready-made phrase was sent instead
🛡️ Вкладку… захищеноThe Instagram tab is protected from being unloaded
Files

Where everything lives

FileWhat it does
~/insta-joker/content.jsRuns inside the Instagram tab: reads chats, patrols the inbox, types replies
background.jsBuilds the prompt, calls both models, cleans up replies, keeps the log
memory.jsFinds your old replies that are most similar to the new message
tools.jsWeather, NBU exchange rates, Wikipedia, web search
defaults.jsDefault settings and the build number
popup.html, popup.jsThe settings window from the toolbar icon
my-replies.jsonYour 713 old reply pairs
learn/build_pairs.pyRebuilds that file from a new Instagram export
watchdog.shReopens Chrome if it closed; writes watchdog.log