// ==UserScript== // @name Rutube custom seek time // @description Скрипт, задающий время перемотки по нажатию стрелок на клавиатуре // @namespace http://tampermonkey.net/ // @version 0.0.2 // @author 4ndefined // @run-at document-end // @match *://rutube.ru/* // @icon https://www.google.com/s2/favicons?sz=64&domain=rutube.ru // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; // Время перемотки в секундах const SEEK_SECONDS = 5; // Исправление размера видео (вкл = 1, выкл = 0) const ENABLE_STYLES_FIX = 1; const video = document.querySelector('[data-testid="video-portal"]'); window.addEventListener('keydown', vidCtrl, true); if (ENABLE_STYLES_FIX) { injectStyles(); } function vidCtrl(e) { const vid = document.querySelector('video'); const key = e.code; e.preventDefault(); e.stopImmediatePropagation(); if (key === 'ArrowLeft') { vid.currentTime -= SEEK_SECONDS; if (vid.currentTime < 0) { vid.pause(); vid.currentTime = 0; } } else if (key === 'ArrowRight') { vid.currentTime += SEEK_SECONDS; if (vid.currentTime > vid.duration) { vid.pause(); vid.currentTime = 0; } } else if (key === 'Space') { if (vid.paused || vid.ended) { vid.play(); } else { vid.pause(); } } } function injectStyles() { const styles = ` .wdp-video-wrapper-module__videoWrapper { padding: 0 !important; height: calc(100vh - 88px); } `; document.head.insertAdjacentHTML("beforeend", ``) } })();