TMDB Video Player

Add video player from 2embed.ru directly into TheMovieDB movie/serie webpage.

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         TMDB Video Player
// @namespace    https://greasyfork.org/fr/scripts/437157-tmdb-video-player
// @version      0.3
// @description  Add video player from 2embed.ru directly into TheMovieDB movie/serie webpage.
// @author       Guillome91
// @license      MIT
// @match        https://www.themoviedb.org/movie/*
// @match        https://www.themoviedb.org/tv/*
// @icon         https://www.themoviedb.org/favicon.ico
// @connect      themoviedb.org
// @connect      2embed.ru
// ==/UserScript==

(function() {
    'use strict';
    //Retrieve api number
    const currentUrl = document.URL;
    const api = currentUrl.replace(/[^0-9]/g, "");
    const type = currentUrl.split('/')[3];
    var player_url,location;
    if(type == "movie"){
        player_url= "https://www.2embed.ru/embed/tmdb/"+type+"?id="+api;
        console.log(player_url);

        //add player
        location = document.querySelector("div.header");
        let ifr = document.createElement("iframe");
        ifr.id = "2embed";
        ifr.height = 800;
        ifr.allowFullscreen = "true";
        ifr.webkitallowfullscreen="true";
        ifr.mozallowfullscreen="true";
        ifr.src = player_url;

        location.after(ifr);
    }

    if(type == "tv"){
        location = document.querySelector("div.header");
        player_url = "https://www.2embed.ru/library/tv/"+api;
        console.log(player_url);
        let div = document.createElement("div");
        div.setAttribute('style','border-radius: 25px;overflow: hidden; margin: 15px auto; max-width: 762px;');
        let ifr = document.createElement("iframe");
        ifr.setAttribute('style',"border: 0px none; margin-left: -20px; height: 850px; margin-top: -150px; width: 800px;");
        ifr.setAttribute('scrolling','no');
        ifr.id = "2embed";
        ifr.src = player_url;
        ifr.allowFullscreen = "true";
        ifr.webkitallowfullscreen="true";
        ifr.mozallowfullscreen="true";
        div.appendChild(ifr);
        location.after(div);
    }
})();