🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

YouTube Restart Video Button

Добавляет кнопку для возврата видео на начало.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         YouTube Restart Video Button
// @namespace    https://github.com/ToLIManl
// @version      0.7
// @description  Добавляет кнопку для возврата видео на начало.
// @description:ru  Добавляет кнопку для возврата видео на начало.
// @description:en  Adds the video return button to the beginning.
// @author       ToLIMan
// @match        https://www.youtube.com/*
// @grant        none
// @license         MIT
// @name:ru         Кнопка воспроизвести видео сначала Youtube
// @name:en         YouTube Restart Video Button
// ==/UserScript==

(function() {
    'use strict';

    // Функция для создания кнопки
    function addRestartButton() {
        const controls = document.querySelector('.ytp-left-controls'); // Панель управления YouTube
        if (!controls || document.querySelector('#restart-button')) return; // Проверка наличия панели и кнопки

        // Создание кнопки
        const button = document.createElement('button');
        button.id = 'restart-button';
        button.textContent = '⏪'; // Иконка кнопки
        button.title = 'Вернуть на начало';
        button.style.cssText = `
            background: none;
            border: none;
            color: white;
            font-size: 16px;
            cursor: pointer;
            padding: 0 10px;
        `;

        // Добавление обработчика нажатия
        button.addEventListener('click', () => {
            const video = document.querySelector('video');
            if (video) {
                video.currentTime = 0; // Устанавливаем время на 0
            }
        });

        // Добавление кнопки в панель управления
        controls.insertBefore(button, controls.firstChild);
    }

    // Наблюдатель для динамического добавления кнопки
    const observer = new MutationObserver(() => {
        addRestartButton();
    });

    observer.observe(document.body, { childList: true, subtree: true });
})();