Скрипт, добавляющий некоторые фишки для рутуба
当前为
// ==UserScript==
// @name Rutube Enhancer
// @description Скрипт, добавляющий некоторые фишки для рутуба
// @namespace http://tampermonkey.net/
// @version 0.0.9
// @author 4ndefined
// @run-at document-end
// @match *://rutube.ru/*
// @match *://rutube.sport/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=rutube.ru
// @grant GM.addStyle
// @license MIT
// ==/UserScript==
(function() {
'use strict';
// Время перемотки в секундах
const SEEK_SECONDS = 5;
// Исправление размера видео (вкл = 1, выкл = 0)
const ENABLE_STYLES_FIX = 1;
// Включает макет страницы на всю ширину
const USE_FULL_WIDTH_LAYOUT = 1;
if (ENABLE_STYLES_FIX) {
injectStyles();
}
window.addEventListener('keydown', handleKeyDown, true);
function stopEvent(e) {
e.preventDefault();
e.stopImmediatePropagation();
}
function handleKeyDown(e) {
const vid = document.querySelector('video');
const key = e.code;
if (key === 'ArrowLeft') {
stopEvent(e);
vid.currentTime -= SEEK_SECONDS;
if (vid.currentTime < 0) {
vid.pause();
vid.currentTime = 0;
}
} else if (key === 'ArrowRight') {
stopEvent(e);
vid.currentTime += SEEK_SECONDS;
if (vid.currentTime > vid.duration) {
vid.pause();
vid.currentTime = 0;
}
} else if (key === 'Space') {
stopEvent(e);
if (vid.paused || vid.ended) {
vid.play();
} else {
vid.pause();
}
}
}
function injectStyles() {
const styles = `
.wdp-video-adfox-module__container,
.wdp-auth-offer-popup-module__wrapper {
display: none !important;
}
.wdp-video-wrapper-module__videoWrapper {
padding: 0 !important;
height: calc(100vh - 104px) !important;
}
${USE_FULL_WIDTH_LAYOUT ? `.video-page-container-module__container { max-width: none !important; }` : ''}
`;
const rutubeSportStyles = `
[class*="_headerWrapper_"] {
padding: var(--rt-spacing-8x);
}
#app >div>div>div {
max-width: 1400px;
}
main header {
order: 2;
}
`;
GM.addStyle(styles);
GM.addStyle(rutubeSportStyles);
}
})();