您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Unmutes the current Facebook Reel video and pauses it when the tab is backgrounded.
// ==UserScript== // @name Facebook Reels Unmuter with Pause // @namespace UserScript // @match https://www.facebook.com/reel/* // @version 2.7 // @license MIT // @author Jason8 // @description Unmutes the current Facebook Reel video and pauses it when the tab is backgrounded. // @icon https://www.google.com/s2/favicons?sz=64&domain=facebook.com // @run-at document-start // @grant none // ==/UserScript== (function() { 'use strict'; let hasUnmuted = false; // Function to find the unmute button and click it function clickUnmuteButton() { if (hasUnmuted) return; const unmuteButton = document.querySelector('[aria-label="Unmute"]'); if (unmuteButton) { unmuteButton.click(); hasUnmuted = true; console.log('Unmute button clicked. Script finished.'); } } // Initialize the script function init() { try { console.log('Facebook Reels Unmuter initialized'); const intervalID = setInterval(() => { if (hasUnmuted) { clearInterval(intervalID); return; } clickUnmuteButton(); }, 250); // Add a safety timeout to stop the interval after 10 seconds setTimeout(() => { if (!hasUnmuted) { clearInterval(intervalID); console.log('Unmute failed after 10 seconds. Timeout reached.'); } }, 10000); // Add a visibility change listener to handle pausing document.addEventListener('visibilitychange', () => { if (document.hidden) { document.querySelectorAll('video').forEach(video => video.pause()); } else { // Removed autoplay code when focus returns to Reels tab } }, true); // Clean up on page unload window.addEventListener('beforeunload', () => { document.removeEventListener('visibilitychange', () => {}, true); }); } catch (e) { console.error('Error initializing Facebook Reels Unmuter with Pause:', e); } } // Start the script if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { setTimeout(init, 500); } })();