OleVod Multimedia

A script to allow olevod site adapt multimedia key to next or previous episode

当前为 2023-09-29 提交的版本,查看 最新版本

// ==UserScript==
// @name         OleVod Multimedia
// @namespace    http://tampermonkey.net/
// @version      0.2.1
// @description  A script to allow olevod site adapt multimedia key to next or previous episode
// @author       You
// @match        *://*.olevod.me/*
// @match        *://*.olevod.com/*
// @match        *://*.olehdtv.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=olevod.me
// @require      https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js
// @require      https://cdn.jsdelivr.net/npm/[email protected]/dist/js.cookie.min.js
// @grant        GM_xmlhttpRequest
// @license      MIT
// ==/UserScript==
/* global $ */

(function() {
    'use strict';

    const toggleFullscreen = (videoElement) => {
        if (videoElement.requestFullscreen) {
            videoElement.requestFullscreen();
        } else if (videoElement.mozRequestFullScreen) {
            videoElement.mozRequestFullScreen();
        } else if (videoElement.webkitRequestFullscreen) {
            videoElement.webkitRequestFullscreen();
        } else if (videoElement.msRequestFullscreen) {
            videoElement.msRequestFullscreen();
        }
    };

    const exitFullscreen = () => {
        if (document.fullscreenElement && document.exitFullscreen) {
            document.exitFullscreen();
            parent.focus();
        }
    };

    document.addEventListener("keydown", (event) => {
        const iframeElement = document.querySelector('iframe[name="pif"]');
        const videoElement = iframeElement?.contentDocument?.querySelector("video");

        if (videoElement) {
            if (event.key === 'f' || event.keyCode === 70) {
                toggleFullscreen(videoElement);
            }
        }

        if (event.keyCode === 176) {
            exitFullscreen();
            parent.$(".next-t").click();
        }

        if (event.keyCode === 177) {
            exitFullscreen();
            parent.$(".pre-t").click();
        }
    });
})();