Greasy Fork

Greasy Fork is available in English.

Better FMovies

Stay Fullscreen, Switch to Next Season on Last Episode, Skip Intro

当前为 2023-12-20 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Better FMovies
// @description  Stay Fullscreen, Switch to Next Season on Last Episode, Skip Intro
// @version      0.1.3
// @require      http://code.jquery.com/jquery-latest.js
// @include      /https?://(www\.)?fmoviesz\.to\/tv/
// @run-at       document-idle
// @namespace http://greasyfork.icu/users/1235006
// ==/UserScript==

(function () {
    const fullScreenBtn = document.createElement("div");
    const fullScreenBtnContent = document.createTextNode("Stay Fullscreen");
    fullScreenBtn.id = "fullscreen-btn";
    fullScreenBtn.classList.add("item");
    fullScreenBtn.appendChild(fullScreenBtnContent);

    const bottomButtons = document.querySelector(".c-items");
    bottomButtons.appendChild(fullScreenBtn);

    fullScreenBtn.addEventListener("click", function () {
        var elem = document.getElementById("player");
        var fn =
            elem.requestFullscreen ||
            elem.mozRequestFullScreen ||
            elem.webkitRequestFullscreen ||
            elem.msRequestFullscreen;

        if (fn) {
            fn.call(elem);
        }
    });

    const addSkipTimeBtn = document.createElement("div");
    addSkipTimeBtn.classList.add("item");
    const addSkipTimeBtnContent = document.createTextNode("Add skip time");
    addSkipTimeBtn.appendChild(addSkipTimeBtnContent);

    let skipTime;
    addSkipTimeBtn.addEventListener("click", function () {
        let skipTimeRaw = prompt(
            "Please enter a valid time for when intro ends (00:00:00):"
        );
        let a = skipTimeRaw.split(":");
        skipTime = +a[0] * 60 * 60 + +a[1] * 60 + +a[2];
    });

    bottomButtons.appendChild(addSkipTimeBtn);

    function receiveMessage(e) {
        let visibleEpisodes = $("ul.episodes:visible");
        let episodeLinks = Array.from(visibleEpisodes.find("a"));
        let lastEpisode = episodeLinks[episodeLinks.length - 1];

        let r = e.message || e.data || e.originalEvent.data;
        let p = JSON.parse(r);
        console.log(p);

        if (p.event === "META_LOADED") {
            if (skipTime) {
                document
                    .querySelector("#player iframe")
                    .contentWindow.postMessage(
                        JSON.stringify({
                            cmd: "SEEK",
                            value: skipTime,
                        }),
                        "*"
                    );
            }
        }

        if (lastEpisode.classList.contains("active")) {
            if (p.event === "PLAY_COMPLETED") {
                let currentSeason = visibleEpisodes.attr("data-season");
                let nextSeason =
                    $("ul.episodes").find(":visible").prevObject[currentSeason];
                if (typeof nextSeason !== "undefined") {
                    nextSeason.querySelector("a").click();
                }
            }
        }
    }

    window.addEventListener("message", receiveMessage);
})();