Insertion variants are the core mechanism for modifying VK.com pages. Each variant defines how to extract data from the page, what services to call, and what UI elements to inject.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/botnadzor/extension/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The insertion system is:- Config-driven: Behavior is defined by JSON configs loaded from static lists
- Type-safe: Full TypeScript typing for configs, data, and services
- Reactive: Uses Pollable pattern for real-time updates
- Modular: Each variant is independent with clear data flow
Architecture
Each insertion variant follows this data flow:Available Variants
Botnadzor includes four insertion variants:1. Account Variant
Purpose: Enhances VK profile pages and account links throughout the site. File:src/entrypoints/content/insertion-variants/=account.ts
Markup Data Extracted:
accountAvatarUrl: Profile picture URLaccountIdentifier: VK domain (e.g.,id123ornickname)accountName: Display name
accountAffiliation: Tags and colors from static listsfrontendBaseUrl: Base URL for Botnadzor links
- Action Bar: Inspector trigger, reg date fetch button
- Affiliation Badge: Colored tag indicator
- Affiliation Highlight: Background color overlay
- Reg Date Display: Shows registration date when fetched
2. Comment Variant
Purpose: Enhances comments on posts, photos, and videos. File:src/entrypoints/content/insertion-variants/=comment.ts
Markup Data Extracted:
accountAvatarUrl: Commenter’s avataraccountIdentifier: Commenter’s VK domainaccountName: Commenter’s namecommentIdentifier: Comment URL parts (wallVkId, postVkId, commentVkId)postCommentCount: Total comments on the post
accountAffiliation: Tags and colorsfrontendBaseUrl: Base URL for links
- Comment Collection: Automatically collects comment metadata if user has opted in (via
CollectingService) - Inspector Trigger: Can open inspector with comment context
/wall-123_456?reply=789https://vk.com/photo-123_456?reply=789replyClick('wall-123_456', 789)replyClick('-123_photo456', 789)
src/entrypoints/content/insertion-variants/=comment.ts:62-148
3. Reply Form Variant
Purpose: Adds a “quick attach bot card” button to reply forms when replying to known bots. File:src/entrypoints/content/insertion-variants/=reply-form.ts
Markup Data Extracted:
accountIdentifier: The account being replied to
accountAffiliation: Checks if account hasbotnadzorCard: truefrontendBaseUrl: For generating card links
- Monitors reply form for changes (MutationObserver)
- Shows button only when replying to an account with
botnadzorCard: true - Clicking button injects a Botnadzor card link into the reply
src/entrypoints/content/insertion-variants/=reply-form.ts:17-70
4. Review Variant
Purpose: Enhances VK community reviews (separate from comments). File:src/entrypoints/content/insertion-variants/=review.ts
Markup Data Extracted:
accountAvatarUrl: Reviewer’s avataraccountIdentifier: Reviewer’s VK domainaccountName: Reviewer’s namereviewIdentifier: Review ID parts (wallVkId, reviewVkId)
accountAffiliation: Tags and colorsfrontendBaseUrl: Base URL for links
review-123_456 format:
src/entrypoints/content/insertion-variants/=review.ts:49-71
Variant Structure
All variants are defined usingdefineInsertionVariant<Config, InnerData, MarkupData, ServiceData>():
Configuration Schema
Each variant has a config schema defined insrc/shared/@model/insertion-configs/:
Common Config Properties
Data Selectors
Data is extracted usingStringDataSelector or ElementSelector:
UI Placement
UI components useUiPlacement:
Markup Edits
Shared UI Components
Variants use shared UI components fromsrc/entrypoints/content/insertion-variants/shared/@markup-ui/:
Action Bar
- Inspector trigger button
- Registration date fetch button
- Account card link
Affiliation Badge
Affiliation Highlight
Reg Date Display
Registering New Variants
To add a new variant:-
Create the variant file in
src/entrypoints/content/insertion-variants/: -
Define the config schema in
src/shared/@model/insertion-configs/: -
Register in the union type in
src/shared/@model/insertion-configs.ts: - Add to insertion system (handled automatically by the variant registry)
- Deploy configs via static lists (insertions list)
Best Practices
Selector Stability
- Prefer
data-*attributes over class names (VK frequently changes classes) - Use
observeSelectorthat matches the insertion scope precisely - Test with React DevTools to find stable selectors
Performance
- Extract markup data asynchronously in parallel
- Use
revalidateMarkupData()sparingly (triggers full re-extraction) - Cache service data when possible
Error Handling
- Always validate extracted data with
warnAboutUndefinedFields() - Return
undefinedfromgetMarkupData()when required fields are missing - Use
omitUndefined()to clean up service data
Tailwind CSS
- Use
bn:prefix for all Tailwind classes in insertion variants - This prevents style conflicts with VK’s CSS
- Example:
bn:text-red-500 bn:font-bold
Icons
- Import from
lucide-static, notlucide-react - Example:
import { UserPlus } from "lucide-static" - This avoids React hydration issues in content scripts