🐾 Toto Image Swapper Script
A powerful script to swap main images with additional images for any case in the Toto platform.
🚀 Quick Start
For Brutus (or any case):
Windows PowerShell (Easiest):
# Navigate to scripts directory
cd toto/scripts
# Super simple - just run:
.\swap-image.ps1 brutus
# Or use full commands:
.\swap-image.ps1 swap Brutus
.\swap-image.ps1 list
.\swap-image.ps1 details Brutus
Node.js (Cross-platform):
# Navigate to scripts directory
cd toto/scripts
# Swap Brutus's image
node swap-case-image.js swap Brutus
# List all cases
node swap-case-image.js list
# Show case details
node swap-case-image.js details Brutus
📋 Available Commands
| Command | Description | Example |
|---|---|---|
list | Show all cases with image info | .\swap-image.ps1 list |
details <case> | Show detailed case information | .\swap-image.ps1 details Brutus |
swap <case> | Swap main image with random additional | .\swap-image.ps1 swap Brutus |
🎯 Quick Shortcuts (PowerShell only)
Instead of typing swap <name>, you can just use the case name:
.\swap-image.ps1 brutus # Swaps Brutus's image
.\swap-image.ps1 luna # Swaps Luna's image
.\swap-image.ps1 shadow # Swaps Shadow's image
.\swap-image.ps1 coal # Swaps Coal's image
.\swap-image.ps1 daisy # Swaps Daisy's image
📊 What It Does
- Finds the case by name or ID in Firestore
- Checks for additional images - won't work if case has no additional images
- Randomly selects one additional image to become the new main image
- Swaps the images:
- Selected additional image → becomes main image
- Old main image → goes to the additional images array
- Updates the database with the new image configuration
- Shows success confirmation with details
🖼️ Example Output
🔍 Looking for case: Brutus
✅ Found case: Brutus (ID: abc123)
🖼️ Current main image: case6_(1).png
📚 Additional images (4): case6_(2).png, case6_(3).png, case6_(4).png, case6_(5).png
🔄 Swapping images...
New main: case6_(3).png
Updated additional: case6_(2).png, case6_(4).png, case6_(5).png, case6_(1).png
✅ Successfully swapped images for Brutus!
🎯 Old main image is now at position 4 in additional images
⚙️ Requirements
- Node.js installed on your system
- Firebase Admin credentials (already configured in the project)
- Case must have additional images to swap with
🔍 Case Identification
The script can find cases by:
- Case Name:
"Brutus","Luna","Shadow", etc. - Case ID: Full Firestore document ID
🛡️ Safety Features
- Validates case exists before attempting swap
- Checks for additional images before proceeding
- Preserves all images - nothing is deleted, just rearranged
- Updates timestamp to track when swap occurred
- Detailed logging shows exactly what happened
🎨 Use Cases
- Testing different main images for cases
- A/B testing which image gets better engagement
- Refreshing case appearance without uploading new images
- Quick image rotation for variety
🚨 Notes
- The swap is permanent until you run it again
- Only works with cases that have additional images
- Changes are immediately reflected in the live app
- Random selection means you can't choose which specific image becomes main
Happy swapping! 🐾✨