您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
This script prevents autoplayed videos on YouTube channel profile pages.
// ==UserScript== // @name Prevent Autoplay On YouTube Channels // @description This script prevents autoplayed videos on YouTube channel profile pages. // @namespace http://tampermonkey.net/ // @icon https://cdn-icons-png.flaticon.com/64/2504/2504965.png // @version 0.0.5 // @author rxm // @match https://www.youtube.com/@*/featured // @match https://www.youtube.com/@* // @match https://www.youtube.com/* // @exclude https://www.youtube.com/watch?v=* // @license MIT // @grant none // ==/UserScript== // Custom urlchange event (used to monitor URL changes) function addUrlChangeEvent() { history.pushState = (f => function pushState() { const ret = f.apply(this, arguments); window.dispatchEvent(new Event('pushstate')); window.dispatchEvent(new Event('urlchange')); return ret; })(history.pushState); history.replaceState = (f => function replaceState() { const ret = f.apply(this, arguments); window.dispatchEvent(new Event('replacestate')); window.dispatchEvent(new Event('urlchange')); return ret; })(history.replaceState); window.addEventListener('popstate', () => { window.dispatchEvent(new Event('urlchange')); }); } if (window.onurlchange === undefined) { addUrlChangeEvent(); } // === Main Logic === (function () { 'use strict'; function isChannelPage() { return location.pathname.startsWith('/@') || location.pathname.startsWith('/channel/'); } function pauseVideo() { if (!isChannelPage()) return; const video = document.querySelector('video'); if (video && !video.paused) { video.pause(); } } // MutationObserver to monitor changes const observer = new MutationObserver(() => { pauseVideo(); }); observer.observe(document.body, { childList: true, subtree: true }); // Initial run pauseVideo(); // Fallback interval for early loads let executionCount = 0; const intervalId = setInterval(() => { pauseVideo(); executionCount++; if (executionCount >= 2) { clearInterval(intervalId); } }, 1000); })();