Rutube - Block Autoplay

Blocks video autoplay on Rutube and in embed players by freezing the player's autoplay behavior.

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

作者のサイトでサポートを受ける。または、このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Rutube - Block Autoplay
// @name:ru      Rutube - Блокировка автовоспроизведения
// @namespace    rutube-block-autoplay
// @version      1.0
// @description  Blocks video autoplay on Rutube and in embed players by freezing the player's autoplay behavior.
// @description:ru     Блокирует автозапуск видео на сайте Rutube и во встроенных плеерах через заморозку автозапуска плеера.
// @author       Vikindor (https://vikindor.github.io/)
// @homepageURL  https://github.com/Vikindor/rutube-block-autoplay
// @supportURL   https://github.com/Vikindor/rutube-block-autoplay/issues
// @license      MIT
// @match        https://rutube.ru/video/*
// @match        https://rutube.ru/play/embed/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function () {
    'use strict';

    const observer = new MutationObserver((mutations, obs) => {
        const video = document.querySelector('video');
        if (video) {
            video.pause();
            video.autoplay = false;
            video.removeAttribute('autoplay');

            const originalPlay = video.play;
            let firstCall = true;

            video.play = function (...args) {
                if (firstCall) {
                    firstCall = false;
                    return Promise.reject('Autoplay prevented');
                }
                return originalPlay.apply(this, args);
            };

            obs.disconnect();
        }
    });

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