您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Allow Facebook Stories to play in the background while leaving regular videos untouched
// ==UserScript== // @name Facebook Stories Background Playback // @namespace http://tampermonkey.net/ // @version 2.2 // @description Allow Facebook Stories to play in the background while leaving regular videos untouched // @author HaiDang // @match https://www.facebook.com/* // @icon https://cdn3.iconfinder.com/data/icons/transparent-on-dark-grey/500/icon-02-512.png // @grant none // ==/UserScript== (function() { 'use strict'; const CHECK_INTERVAL = 1000; const STORY_CONTAINER_SELECTORS = [ 'div[role="dialog"]', 'div[aria-label="Tin"]', '.x78zum5.xdt5ytf.xg6iff7' ]; function findStoryContainer() { for (const selector of STORY_CONTAINER_SELECTORS) { const container = document.querySelector(selector); if (container) return container; } return null; } function simulateFocus(element) { if (!element) return; // Create and dispatch focus event const focusEvent = new FocusEvent('focus', { view: window, bubbles: true, cancelable: true }); // Create and dispatch mouseenter event const mouseEvent = new MouseEvent('mouseenter', { view: window, bubbles: true, cancelable: true }); element.dispatchEvent(focusEvent); element.dispatchEvent(mouseEvent); } function initAutoplay() { setInterval(() => { const storyContainer = findStoryContainer(); if (storyContainer) { simulateFocus(storyContainer); const videoElements = storyContainer.querySelectorAll('video'); videoElements.forEach(video => { if (video.paused) { video.play().catch(() => { }); } }); } }, CHECK_INTERVAL); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', initAutoplay); } else { initAutoplay(); } })();