您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Pause youTube video/music with Alt+K on any page
// ==UserScript== // @name [Youtube Music] Pause video/music with Alt+K on any page // @namespace https://greasyfork.org/users/821661 // @match https://*/* // @grant GM_getValue // @grant GM_setValue // @grant GM_addValueChangeListener // @version 1.1 // @author hdyzen // @description Pause youTube video/music with Alt+K on any page // @license GPL-3.0-only // ==/UserScript== function init() { const domain = window.location.hostname; if (domain === "music.youtube.com") { onYoutubeMusic(); } onEveryPage(); } init(); function onEveryPage() { window.addEventListener("keydown", handlerKey); } function onYoutubeMusic() { const callback = () => { const video = document.querySelector(".video-stream"); video.paused ? video.play() : video.pause(); }; GM_addValueChangeListener("toggleVideo", callback); } function handlerKey(ev) { const isAltKPressed = ev.altKey && ev.code === "KeyK"; if (!isAltKPressed) { return; } GM_setValue("toggleVideo", !GM_getValue("toggleVideo")); }