Greasy Fork

Greasy Fork is available in English.

TVer click play

Tverの再生画面クリックで、再生開始・停止を行えるようにします

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        TVer click play
// @namespace   TVer click play
// @match       https://tver.jp/*
// @grant       none
// @version     1.2
// @author      hamachi
// @description Tverの再生画面クリックで、再生開始・停止を行えるようにします
// @license     MIT license
// @icon        https://tver.jp/favicon.ico
// @compatible  firefox
// @compatible  chrome
// ==/UserScript==

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

const controllerElement = "[class*='controller_container__']";
const progressElement = "[class*='progress_container__']";

const observer = new MutationObserver(() => {
    if (saveURL && saveURL != location.href) {
        isValid = false;
    }

    if (regex.test(location.href)) {
        const target = document.querySelector(controllerElement);

        if (target && !isValid) {
            saveURL = location.href;
            const video = document.querySelector("video");

            document.querySelector(progressElement).style.margin = "5px 8px 0px";
            const cover = document.querySelector(controllerElement);
            cover.insertAdjacentHTML(
                "afterbegin",
                '<div id="player-cover" style="z-index: -1; height: 100%; width: 100%;"></div>'
            );
            const playerCover = document.querySelector("#player-cover");

            playerCover.addEventListener("click", () => {
                if (video.paused) {
                    video.play();
                } else {
                    video.pause();
                }
            });
            isValid = true;
        }
    }
});
const config = { childList: true, subtree: true };
observer.observe(document.getElementById("__next"), config);