IMDb 播放器

在 IMDb 上免费观看电影和电视剧

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         IMDb Player
// @name:tr      IMDb Oynatıcı
// @name:de      IMDb Player
// @name:fr      Lecteur IMDb
// @name:es      Reproductor de IMDb
// @name:pt      Reprodutor IMDb
// @name:pt-BR   Reprodutor do IMDb
// @name:ru      IMDb Плеер
// @name:ja      IMDb プレーヤー
// @name:zh-CN   IMDb 播放器
// @name:zh-TW   IMDb 播放器
// @name:ar      مشغل IMDb
// @name:hi      IMDb प्लेयर
// @name:it      Lettore IMDb
// @name:pl      Odtwarzacz IMDb
// @name:ko      IMDb 플레이어
// @name:nl      IMDb Speler
// @name:id      Pemutar IMDb
// @name:vi      Trình phát IMDb
// @name:th      เครื่องเล่น IMDb
// @name:uk      IMDb Програвач
// @name:cs      Přehrávač IMDb
// @name:sv      IMDb Spelare
// @name:da      IMDb Afspiller
// @name:fi      IMDb Toistin
// @name:no      IMDb Spiller
// @name:el      IMDb Πρόγραμμα αναπαραγωγής
// @name:ro      Player IMDb
// @name:hu      IMDb Lejátszó
// @name:sk      Prehrávač IMDb
// @name:bg      IMDb Плейър
// @name:hr      IMDb Player
// @name:sr      IMDb Плејер
// @name:lt      IMDb Grotuvas
// @name:lv      IMDb Atskaņotājs
// @name:et      IMDb Mängija
// @name:ms      Pemain IMDb
// @name:fil     IMDb Player
// @description  Watch movies and TV shows for free on IMDb
// @description:tr  IMDb üzerinde filmleri ve dizileri ücretsiz izleyin
// @description:de  Filme und Serien kostenlos auf IMDb ansehen
// @description:fr  Regardez des films et séries gratuitement sur IMDb
// @description:es  Mira películas y series gratis en IMDb
// @description:pt  Assista filmes e séries gratuitamente no IMDb
// @description:pt-BR Assista filmes e séries gratuitamente no IMDb
// @description:ru  Смотрите фильмы и сериалы бесплатно на IMDb
// @description:ja  IMDbで映画やドラマを無料で視聴
// @description:zh-CN 在 IMDb 上免费观看电影和电视剧
// @description:zh-TW 在 IMDb 上免費觀看電影和電視劇
// @description:ar  شاهد الأفلام والمسلسلات مجانًا على IMDb
// @description:hi  IMDb पर फिल्में और टीवी शो मुफ्त में देखें
// @description:it  Guarda film e serie TV gratuitamente su IMDb
// @description:pl  Oglądaj filmy i seriale za darmo na IMDb
// @description:ko  IMDb에서 영화와 TV 프로그램을 무료로 시청
// @description:nl  Bekijk gratis films en series op IMDb
// @description:id  Tonton film dan serial TV gratis di IMDb
// @description:vi  Xem phim và chương trình TV miễn phí trên IMDb
// @description:th  ดูภาพยนตร์และซีรีส์ฟรีบน IMDb
// @description:uk  Дивіться фільми та серіали безкоштовно на IMDb
// @description:cs  Sledujte filmy a seriály zdarma na IMDb
// @description:sv  Titta på filmer och serier gratis på IMDb
// @description:da  Se film og serier gratis på IMDb
// @description:fi  Katso elokuvia ja sarjoja ilmaiseksi IMDb:ssä
// @description:no  Se filmer og serier gratis på IMDb
// @description:el  Δείτε ταινίες και σειρές δωρεάν στο IMDb
// @description:ro  Urmăriți filme și seriale gratuit pe IMDb
// @description:hu  Nézz filmeket és sorozatokat ingyen az IMDb-n
// @description:sk  Sledujte filmy a seriály zadarmo na IMDb
// @description:bg  Гледайте филми и сериали безплатно в IMDb
// @description:hr  Gledajte filmove i serije besplatno na IMDb
// @description:sr  Гледајте филмове и серије бесплатно на IMDb
// @description:lt  Žiūrėkite filmus ir serialus nemokamai IMDb
// @description:lv  Skatieties filmas un seriālus bez maksas IMDb
// @description:et  Vaadake filme ja sarju tasuta IMDb-s
// @description:ms  Tonton filem dan siri TV secara percuma di IMDb
// @description:fil Panoorin ang mga pelikula at palabas nang libre sa IMDb
// @namespace    https://greasyfork.org/users/1372128
// @version      1.2
// @author       Dragon9135
// @match        *://www.imdb.com/title/*
// @match        *://www.imdb.com/*/title/*
// @icon         https://www.imdb.com/favicon.ico
// @grant        none
// @license      MPL-2.0
// ==/UserScript==

(function () {
    'use strict';

    function getIMDbID() {
        const match = window.location.pathname.match(/title\/(tt\d+)/);
        return match ? match[1] : null;
    }

    function isTVSeries() {
        return document.body.innerText.includes("Episode guide");
    }

    function hasWatchedButton() {
        return document.querySelector('[data-testid^="watched-button-"]') !== null;
    }

    function createButton(url) {
        const btn = document.createElement("button");

        btn.className = "ipc-btn ipc-btn--full-width ipc-btn--left-align-content ipc-btn--large-height ipc-btn--core-baseAlt ipc-btn--theme-baseAlt ipc-btn--button-radius ipc-btn--on-accent2 ipc-secondary-button sc-104ed846-1 bmBzwD";
        btn.style.marginTop = "8px";
        btn.innerText = "Watch for free";

        btn.onclick = () => {
            window.open(url, "_blank");
        };

        return btn;
    }

    function addButton() {
        const container = document.querySelector(".sc-dcb1530e-3.hgRMPJ");
        if (!container) return;

        if (!hasWatchedButton()) return;

        if (document.getElementById("custom-watch-btn")) return;

        const imdbID = getIMDbID();
        if (!imdbID) return;

        const isSeries = isTVSeries();

        const url = isSeries
            ? `https://vidfast.pro/tv/${imdbID}/1/1?nextButton=true&autoNext=true`
            : `https://vidfast.pro/movie/${imdbID}`;

        const btn = createButton(url);
        btn.id = "custom-watch-btn";

        container.appendChild(btn);
    }

    addButton();

    const observer = new MutationObserver(() => {
        addButton();
    });

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

})();