您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Keep playing Instagram reels in the background & Prevent them from pausing when switching to another tab.
// ==UserScript== // @name Keep playing Instagram Reels in the background // @namespace cougar16 // @version 1.6 // @description Keep playing Instagram reels in the background & Prevent them from pausing when switching to another tab. // @match https://www.instagram.com/ // @match https://www.instagram.com/* // @icon https://www.google.com/s2/favicons?domain=instagram.com&sz=32 // @license MIT // ==/UserScript== (function () { 'use strict'; function keepPlaying(video) { if (video._patched) return; video._patched = true; const originalPause = video.pause; const originalPlay = video.play; video.pause = function () { if (document.hidden) return; return originalPause.call(this); }; video.addEventListener('play', () => { document.querySelectorAll('video').forEach(v => { if (v !== video && !v.paused) { v.pause(); } }); }); video.play = function () { return originalPlay.call(this); }; } const observer = new MutationObserver(mutations => { mutations.forEach(mutation => { mutation.addedNodes.forEach(node => { if (node.nodeName === 'VIDEO') { keepPlaying(node); } else if (node.querySelectorAll) { node.querySelectorAll('video').forEach(keepPlaying); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); document.querySelectorAll('video').forEach(keepPlaying); })();