Greasy Fork is available in English.

Background Video Playback Fix (Instagram, Facebook, Reddit, TikTok)

Prevents videos from pausing when the tab/window loses visibility or focus. Spoofs Page Visibility API, blocks lifecycle events, and auto-resumes videos paused by the site.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

作者
piknockyou
今日安裝
0
安裝總數
36
評價
1 0 0
版本
1.7
建立日期
2026-01-02
更新日期
2026-01-24
尺寸
15.2 KB
授權條款
AGPL-3.0
腳本執行於

☕ If you find this tool helpful & would like to support its maintenance, please consider leaving a tip on:

https://ko-fi.com/piknockyou

Thank you! :-)


Background Video Playback Fix (Instagram, Facebook, Reddit, TikTok)

Prevents videos from pausing when you switch tabs, minimize the browser, or the window loses focus. Works on Instagram, Facebook, Reddit, and TikTok.

Why You Need This

Modern web apps aggressively pause media the moment you leave the tab:

  • Instagram pauses Reels/Stories on visibilitychange
  • Facebook pauses Stories and in-feed videos
  • TikTok halts playback entirely when backgrounded
  • Reddit stops video players on blur/visibility loss

This script spoofs visibility state, blocks lifecycle events, and auto-resumes videos paused by the site—not by you.

What It Does

Visibility API Spoofing

  • Makes document.hidden always return false
  • Makes document.visibilityState always return "visible"
  • Covers legacy webkit-prefixed properties

Event Blocking

  • Blocks visibilitychange, pagehide, pageshow, freeze, resume from reaching site scripts
  • Optionally blocks focus/blur events (some sites pause on blur instead)

Smart Auto-Resume

  • Detects when the site force-pauses a video while you're actually backgrounded
  • Automatically calls play() to resume
  • Respects intentional pauses: if you clicked pause (or any gesture) within the last ~1.5 seconds, it won't fight you
  • Skips ended videos, errored videos, and videos not yet loaded

SPA-Aware

  • Uses MutationObserver to catch dynamically loaded videos (all these sites are single-page apps)
  • Checks shadow DOM roots for embedded players

Important Notes

  • Desktop browsers only. Mobile browsers/OSes often have their own background media restrictions that userscripts cannot override.
  • Won't bypass autoplay policies. If the browser blocks autoplay (e.g., unmuted video without prior interaction), this script can't force it.
  • Focus/blur blocking may have side effects. Messaging apps may not mark messages as "seen" correctly. Disable blockFocusBlurEvents in the config if needed.

Configuration

All options are in the CONFIG object at the top of the script:

Option Default Description
spoofVisibilityAPI true Spoof document.hidden / visibilityState
blockVisibilityEvents true Block visibility/lifecycle events
blockFocusBlurEvents true Block focus/blur events
autoResumeVideos true Auto-resume videos paused by the site
userGestureGraceMs 1500 Time (ms) after a gesture to treat pause as intentional
debug false Enable console logging

Installation

  1. Install a userscript manager:
  2. Install this script
  3. Works automatically on supported sites

Supported Sites

  • instagram.com
  • facebook.com
  • reddit.com
  • tiktok.com

Troubleshooting

Problem Solution
Video still pauses Enable debug: true and check console for clues
Site features broken Try disabling blockFocusBlurEvents
Doesn't work on mobile Browser/OS-level restrictions; not fixable via userscript