-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiframe_api-replacer.user.js
77 lines (66 loc) · 1.53 KB
/
iframe_api-replacer.user.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// ==UserScript==
// @name MovieLaLa iframe_api Replacer
// @namespace http://embed.movielala.com/
// @version 1.0.0
// @author MovieLaLa
// @match *://*/*
// @grant none
// @run-at document-start
// ==/UserScript==
// Only run on parent windows
if (window.parent && window.parent !== window) {
return;
}
/*
Configuration
*/
var newWidgetURL = 'https://d20psk4uwj5q3z.cloudfront.net/www-widgetapi.js';
var newHost = 'https://embed.movielala.com';
/*
Patched iframe_api
*/
window.YT = {
loading: 1,
loaded: 0
};
window.YTConfig = {
'host': newHost
};
(function() {
var l = [];
YT.ready = function(f) {
if (YT.loaded) {
f();
} else {
l.push(f);
}
};
window.onYTReady = function() {
YT.loaded = 1;
for (var i = 0; i < l.length; i++) {
try {
l[i]();
} catch (e) {}
}
// We will load very fast, even before the patched website declares onYouTubeIframeAPIReady() so watch for it
var interval = window.setInterval(function () {
if (typeof window.onYouTubeIframeAPIReady === 'function') {
window.onYouTubeIframeAPIReady();
window.clearInterval(interval);
}
}, 100);
};
YT.setConfig = function(c) {
for (var k in c) {
if (c.hasOwnProperty(k)) {
YTConfig[k] = c[k];
}
}
};
var a = document.createElement('script');
a.type = 'text/javascript';
a.id = 'www-widgetapi-script';
a.src = newWidgetURL;
a.async = true;
window.document.head.appendChild(a);
})();