-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuserscript.js
59 lines (51 loc) · 1.83 KB
/
userscript.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// ==UserScript==
// @name VidSrc.Me TMDB Video Player
// @namespace
// @version 0.0.1
// @updateURL https://raw.githubusercontent.com/Tommy0412/VidSrc.Me-TMDB-Video-Player/main/userscript.js
// @downloadURL https://raw.githubusercontent.com/Tommy0412/VidSrc.Me-TMDB-Video-Player/main/userscript.js
// @description VidSrc.Me TMDB Video Player
// @author Tommy0412
// @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 vidsrc.xyz
// ==/UserScript==
(function() {
'use strict';
const currentUrl = document.URL;
const type = currentUrl.split('/')[3];
const match = type === "tv" ? currentUrl.match(/\/tv\/(\d+)/) : currentUrl.match(/\/movie\/(\d+)/);
const api = match ? match[1] : "";
var player_url, location, iframeId;
if (type === "movie") {
player_url = `https://vidsrc.xyz/embed/movie/${api}`;
iframeId = "vidsrc.xyz.movie";
} else if (type === "tv") {
player_url = `https://vidsrc.xyz/embed/tv/${api}`;
iframeId = "vidsrc.xyz.tv";
} else {
console.error("Unsupported page type:", type);
return;
}
location = document.querySelector("div.header");
if (!location) {
console.error("Cannot find suitable location to insert iframe.");
return;
}
const existingIframe = document.getElementById(iframeId);
if (existingIframe) {
existingIframe.remove();
}
let ifr = document.createElement("iframe");
ifr.id = iframeId;
ifr.height = 400;
ifr.width = 400;
ifr.allowFullscreen = "true";
ifr.webkitallowfullscreen = "true";
ifr.mozallowfullscreen = "true";
ifr.src = player_url;
location.after(ifr);
})();