TVer click play

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);