Enhanced audio downloader + auto-signup for Brain.fm with ID3 metadata embedding
Enhanced audio downloader + auto-signup for Brain.fm with ID3 metadata embedding
A powerful userscript that adds a draggable widget to Brain.fm, enabling one-click audio downloads with embedded metadata (title, artist, genre, and cover art), plus automated test account creation.
TIT2)TPE1) → "Brain.fm"TCON)APIC) with intelligent resizing & compressionGM_xmlhttpRequest → GM_download → anchor taghttps://my.brain.fm/* and https://brain.fm/*MutationObserverGM_download, GM_xmlhttpRequest, GM_addStyle, GM_getValue, GM_setValue| Setting | Default | Description |
|---|---|---|
| Metadata Embedding | ✅ Enabled | Toggle ID3 tag embedding for MP3 downloads |
Settings persist across sessions using GM_setValue or localStorage fallback.
CONFIG object)const CONFIG = {
WIDGET_ID: 'brainfm-unified-widget-fixed', // Widget DOM ID
POS_KEY: 'brainfm_widget_pos', // Storage key for position
META_KEY: 'brainfm_meta_enabled', // Storage key for metadata toggle
DRAG_THRESHOLD: 3, // Pixels to start drag
OBSERVER_DEBOUNCE: 250, // DOM scan debounce (ms)
DOWNLOAD_TIMEOUT: 120000, // Download timeout (ms)
STATE_CHECK_INTERVAL: 800, // Track info poll interval (ms)
MAX_RETRY_ATTEMPTS: 3, // Unused placeholder
METADATA_ENABLED: true, // Default metadata state
SELECTORS: { /* DOM query selectors for Brain.fm elements */ }
};
⚠️ Modify code-level config only if you understand the script internals.
| Control | Action |
|---|---|
| Drag header | Reposition widget (position saved) |
| ↻ Refresh | Re-scan page for audio/track info |
| 🎧 Download | Start download of current track |
| New Acc | Run automated signup flow |
graph LR
A[Download MP3] --> B{Metadata Enabled?}
B -->|Yes| C[Fetch Cover Art URL]
C --> D[Resize & Compress Image]
D --> E[Create ID3 Frames: TIT2/TPE1/TCON/APIC]
E --> F[Prepend ID3 Tag to Audio Buffer]
F --> G[Download Tagged File]
B -->|No| G
GM_xmlhttpRequest (preferred): Full control, supports post-processing for metadataGM_download: Native manager download (no metadata embedding)// Abstracted storage wrapper
storage.get(key, fallback) // Tries GM_getValue → localStorage
storage.set(key, value) // Tries GM_setValue → localStorage
The script uses multiple fallback strategies to locate track info:
[data-testid="currentTrackTitle"] (player page).bMnsXL, etc.)src attribute| Issue | Possible Cause | Solution |
|---|---|---|
| Widget not appearing | Script not loaded / wrong domain | Check userscript manager is active; ensure URL matches @match patterns |
| Download fails silently | CORS / network error / timeout | Check console for [BrainFM] warnings; try refreshing page |
| Metadata not embedding | File not MP3 / cover fetch failed / ID3 error | Verify file extension; check network tab for cover art 403/404 |
| Widget stuck/dragging | Pointer capture lost | Click refresh button or reload page |
| Auto-signup hangs | Brain.fm form structure changed | Check console for selector warnings; script may need update |
| Position not saving | Storage quota / permissions issue | Clear localStorage for brain.fm; ensure GM_* permissions granted |
%c[BrainFM]✅ Widget initialized → Script loaded successfully🎨 Metadata embedding: enabled → ID3 feature active⚠️ Metadata embedding skipped → Non-critical error, download continues❌ Download failed → Network or processing errorBrain.fm Automator
├── CONFIG // Global settings & selectors
├── ID3Embedder // Minimal MP3 ID3v2.3 writer
├── Styles // Glassmorphism CSS with fallbacks
├── Widget // Draggable UI component manager
├── AudioHandler // Track detection, info parsing, observer
├── Downloader // Multi-method download with metadata pipeline
└── AutoSignup // Form automation with modal handling
GM_xmlhttpRequest with same-origin referer