TVer Click to Play

Stop auto-play on TVer episode pages.

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           TVer Click to Play
// @icon           https://www.google.com/s2/favicons?domain=tver.jp&size=16
// @description    Stop auto-play on TVer episode pages.
// @description:ja TVerの自動再生をストップ(hamachi様のスクリプトをベースに修正)
// @namespace      https://bsky.app/profile/neon-ai.art
// @homepage       https://neon-aiart.github.io/
// @version        1.0
// @author         ねおん
// @match          https://tver.jp/*
// @grant          none
// @run-at         document-idle
// @license        MIT
// @copyright      ねおん (Based on code by hamachi)
// ==/UserScript==

(function() {
    'use strict';

    const regex = /https:\/\/tver\.jp\/episodes\/.+/;
    let saveURL = "";;

    const observer = new MutationObserver(() => {
        const currentURL = location.href;
        if (regex.test(currentURL)) {
            // URLが変わった場合、停止処理を再度行えるようにリセット
            if (saveURL !== location.href) {
                const video = document.querySelector("video");

                // ビデオが見つかり、かつ再生されている(または再生しようとしている)場合
                if (video && !video.paused) {
                    video.pause();
                    video.currentTime = 0;
                    // 1回止めたらこのURLでの自動停止は終了
                    saveURL = currentURL;
                    // console.log("[Debug] Auto-play stopped successfully.");
                }
            }
        } else {
            // エピソードページ以外(トップ画面など)に戻ったらリセット
            saveURL = "";
        }
    });

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