您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Mute or stop videos on Reddit when they are scrolled out of view
// ==UserScript== // @name Reddit Video Pause on Scroll // @namespace http://tampermonkey.net/ // @version 1.0 // @description Mute or stop videos on Reddit when they are scrolled out of view // @author NettiMies // @match https://old.reddit.com/* // @match https://www.reddit.com/* // @grant none // @license gpl-3.0 // ==/UserScript== (function() { 'use strict'; const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { const video = entry.target; if (entry.isIntersecting) { // Video is in view if (video.paused) { video.play(); } video.muted = false; } else { // Video is out of view video.pause(); video.muted = true; } }); }, { threshold: 0.5 // Adjust threshold as needed }); function checkForVideos() { document.querySelectorAll('video').forEach(video => { observer.observe(video); }); } // Check for new videos periodically, I don't know jack about javascript, I just know it sucks balls and is slow as hell, so this might decimate performance... Didn't for me though, so we BALL!! setInterval(checkForVideos, 1000); })();