Forces Page Visibility API to "visible" on selected domains so background video/audio keeps playing.
A lightweight Userscript inspired by Mozilla’s video-bg-play add-on, designed to keep video/audio playing in the background on mobile Firefox (and other browsers using a Userscript manager).
It works by spoofing the Page Visibility API so that websites continue to believe the tab is still visible.
visibilitychange events (more compatible)Many video platforms pause playback when the tab is not visible (background / switched tab / screen locked). This script spoofs these values:
document.visibilityState → "visible"document.hidden → false(Some sites also use WebKit aliases such as document.webkitHidden, which are also spoofed.)
The script only activates on domains listed in two places:
1) Userscript header match rules (// @match ...)
2) Runtime whitelist (CFG.HOST_SUFFIXES)
To add a new website, you must add it to both lists.
Examples included by default:
You need a Userscript manager extension/add-on first.
Recommended:
Install it from Greasy Fork:
Open one of the supported sites and start playing a video/audio stream. Playback should continue even if you switch apps/tabs.
Open the script in your Userscript manager and edit the CFG section at the top.
const CFG = {
ENABLED: true,
// If true, also run inside iframes/embeds
ALLOW_IFRAMES: true,
// Domain whitelist (suffix match)
HOST_SUFFIXES: [
'youtube.com',
'netflix.com',
'spotify.com',
],
// Spoof Page Visibility API
SPOOF_VISIBILITY: true,
// Optional: emit user activity events (default OFF)
SYNTHETIC_ACTIVITY: false,
};