您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Pause your background video when you play another video in another tab.
当前为
// ==UserScript== // @name YouTube: Play Single Video Only // @namespace UserScript // @match https://www.youtube.com/* // @version 1.0 // @license MIT // @author CY Fung // @description Pause your background video when you play another video in another tab. // @run-at document-start // @grant GM_addValueChangeListener // @grant GM.setValue // ==/UserScript== (() => { let listenerId = GM_addValueChangeListener("t9opC", function (key, oldValue, newValue, remote) { if (remote) { let video = document.querySelector('#movie_player video'); if (video && video.paused === false) { HTMLVideoElement.prototype.pause.call(video); } } }); document.addEventListener('play', function (evt) { if (!evt || !evt.isTrusted) return; const target = (evt || 0).target; if (target instanceof HTMLVideoElement) { if (HTMLElement.prototype.matches.call(target, '#movie_player video')) { GM.setValue('t9opC', Date.now()); } } }, true); })();