您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
讓空白鍵像k鍵一樣方便 原始功能依舊保持 所以空白鍵會同時擁有空白鍵和k鍵的效果
// ==UserScript== // @name Youtube強制用空白鍵播放/暫停 // @namespace https://gf.qytechs.cn/scripts/479470 // @version 1.1 // @description 讓空白鍵像k鍵一樣方便 原始功能依舊保持 所以空白鍵會同時擁有空白鍵和k鍵的效果 // @author fmnijk // @match https://www.youtube.com/* // @icon https://www.google.com/s2/favicons?domain=youtube.com // @grant none // @run-at document-end // @license MIT // ==/UserScript== /*main function*/ let old_state = true let new_state = true function kevent(){ const kEvent = new KeyboardEvent("keydown", { keyCode: 75, // k鍵的keyCode是75 bubbles: true, // 事件要冒泡 cancelable: true // 事件要可取消 }); document.activeElement.dispatchEvent(kEvent); } (window.onload = function() { 'use strict'; Object.defineProperty(HTMLMediaElement.prototype, 'playing', { get: function(){ return !!(this.currentTime > 0 && !this.paused && !this.ended && this.readyState > 2); } }) document.addEventListener("keydown", function(event) { // 如果按下的是空格鍵 if (event.keyCode == 32 && event.target != document.querySelector('#movie_player') && event.target != document.querySelector('h2#title')){ console.log(event.target) old_state = document.querySelector(".video-stream.html5-main-video").playing kevent() setTimeout(() => { new_state = document.querySelector(".video-stream.html5-main-video").playing if (new_state == old_state) { kevent() } }, "125"); } }); })
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址