Tampermonkey scripts I use for Facebook: Background Audio Keepalive for Reels and Autoduck + zbluebugz Clean My Feed (https://github.com/zbluebugz/)
Keeps Facebook Reels audio playing when the tab is unfocused.
Facebook pauses Reels audio when the tab loses focus by:
- Using the Page Visibility API
- Monitoring window focus / blur
- Explicitly calling
HTMLMediaElement.pause()
This userscript lies convincingly enough to bypass that behaviour.
- Firefox or Chromium browser
- Tampermonkey (recommended)
- Install Tampermonkey
- Create a new userscript
- Paste the script from
fb-reels-audio-keepalive.user.js - Reload Facebook
- Works by spoofing visibility + focus
- Prevents background-triggered pauses
- Allows clean transition between Reels (no audio looping)
For personal use.
No affiliation with Meta.
Prototype Patch (v1.4)
Hard-blocks Facebook’s “hover / next-reel” volume ducking by patching the HTMLMediaElement.volume setter at runtime. Your chosen volume persists across Reels, hovers, and autoplay transitions.
Designed for Tampermonkey. Runs at document-start.
Facebook frequently reduces (or nearly mutes) audio when:
- Hovering over Reels
- Auto-advancing to the next Reel
- Losing focus or changing playback state
- Reusing
These changes are app-driven, not user intent.
This userscript:
- Blocks non-user-initiated volume drops
- Preserves your last intentional volume level
- Restores volume instantly when ducking is detected
- Survives SPA navigation, element reuse, and source swaps
- Prototype patching: overrides the HTMLMediaElement.volume setter so all volume changes pass through a single gate.
- Gesture detection: tracks real user input (mouse, touch, keyboard) to distinguish intentional volume changes from Facebook automation.
- Ducking heuristics: suspiciously low values are treated as ducking and replaced with the last known user volume.
- Persistence: stores the user’s volume in localStorage and reapplies it across Reels and sessions.
- Resilience: handles reused media elements, src swaps, autoplay quirks, and muted-on-play edge cases.
No DOM polling. No timers. No React internals.
- Blocks hover-based and next-reel volume ducking
- Persists user-selected volume across Reels
- Handles reused
- Survives SPA navigation and autoplay
- Optional auto-unmute on play
- Lightweight toast feedback
- Keyboard toggle
Toggle protection on/off:
- Shift + V
A toast and console message confirm the current state.
Editable constants near the top of the script:
const MIN_DUCK = 0.15;
const DEFAULT_VOLUME = 1.0;
const GESTURE_WINDOW_MS = 1200;
const AUTOUNMUTE_ON_PLAY = true;