您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Use similar controls as on YouTube when watching Showtime (`f` for full screen, `k` to play/pause, `c` for captions, `j` to go back 10 seconds, `l` to go forward 10 seconds)
当前为
// ==UserScript== // @name Showtime: enable YouTube-style keyboard controls // @namespace showtime.keyboard // @version 0.2 // @description Use similar controls as on YouTube when watching Showtime (`f` for full screen, `k` to play/pause, `c` for captions, `j` to go back 10 seconds, `l` to go forward 10 seconds) // @match https://showtime.com/* // @match https://www.showtime.com/* // @grant none // ==/UserScript== (function() { 'use strict'; // change these constants if you prefer to use a different key // (or change the letter to uppercase if you want the shortcut to require the use of Shift) const FULL_SCREEN_KEY = 'f'; const PLAY_PAUSE_KEY = 'k'; const FORWARDS_TEN_SECONDS_KEY = 'l'; const BACKWARDS_TEN_SECONDS_KEY = 'j'; const CLOSED_CAPTIONS_KEY = 'c'; function clickButton(className) { const buttons = document.querySelectorAll('button.' + className); if (buttons && buttons.length == 1) { buttons[0].click(); } else { console.error('Button not found!'); } } function isPlaying(videoElement) { return !!(videoElement.currentTime > 0 && !videoElement.paused && !videoElement.ended && videoElement.readyState > 2); } addEventListener("keypress", function(e) { if (e.ctrlKey || e.altKey) { // return early if any modifier key like Control or Alt is part of the key press return; } const videos = document.getElementsByTagName('video'); const video = videos && videos.length == 1 ? videos[0] : null; if (e.key == FULL_SCREEN_KEY) { clickButton(window.innerHeight == screen.height ? 'exit-fullscreen' : 'enter-fullscreen'); } else if (e.key == PLAY_PAUSE_KEY) { clickButton(video && isPlaying(video) ? 'pause' : 'play'); } else if (e.key == FORWARDS_TEN_SECONDS_KEY && video) { video.currentTime += 10; } else if (e.key == BACKWARDS_TEN_SECONDS_KEY && video) { video.currentTime -= 10; } else if (e.key == CLOSED_CAPTIONS_KEY) { const ccContainer = document.querySelectorAll('div.player-closed-captioning-container > div'); if (ccContainer && ccContainer.length == 1) { clickButton(ccContainer[0].classList.contains('closed-captioning-enabled') ? 'closed-captioning-disable' : 'closed-captioning-enable'); } else { console.error('No CC container found'); } } }); })();