您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
4/2/2022, 11:05:09 PM
// ==UserScript== // @name Youtube Shorts keyboard control // @namespace Violentmonkey Scripts // @match https://www.youtube.com/* // @grant none // @version 3.0 // @run-at document-idle // @license MIT // @author - // @description 4/2/2022, 11:05:09 PM // ==/UserScript== var timer=setInterval(()=>{ console.log('INTERVAL'); if(document.querySelector("#shorts-player > div.html5-video-container > video")!=null && document.querySelector("#shorts-player > div.html5-video-container > video").getAttribute("control")==null){ //console.log('IF'); var vid=document.querySelector("#shorts-player > div.html5-video-container > video"); vid.setAttribute("control",1); //vid.currentTime=vid.currentTime-2; addEventListener("keydown", function(e) { switch (e.key.toUpperCase()) { case "ARROWLEFT": case "A": vid.currentTime=vid.currentTime-5; break; case "ARROWRIGHT": case "D": vid.currentTime=vid.currentTime+5; break; case "ESCAPE": document.querySelector("#items > ytd-guide-entry-renderer:nth-child(1)").click(); //console.log("Exiting"); break; default: console.log(e.key.toUpperCase()); break; } }); //clearInterval(timer); } },1000);