-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathytglow.js
38 lines (38 loc) · 1.44 KB
/
ytglow.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
var fograf;
(function() {
var canvas = document.getElementById("videofog");
if (!canvas) {
canvas = document.createElement("canvas");
canvas.id = "videofog";
canvas.style.position = "absolute";
canvas.style.left = "50%";
canvas.style.transform = "translate(-50%)";
canvas.style.filter = "blur(100px) contrast(1.5)";
canvas.style.mixBlendMode = "lighten";
var context = canvas.getContext("2d");
function updatefog() {
var video = document.querySelector("ytd-watch-flexy video") || document.querySelector("video");
var rect = video.getBoundingClientRect();
canvas.width = 64;
canvas.height = 64 * rect.height / rect.width;
canvas.style.width = rect.width + "px";
canvas.style.height = rect.height + "px";
context.drawImage(video, 0, 0, canvas.width, canvas.height);
fograf = requestAnimationFrame(updatefog);
}
function waitForContainer() {
try {
var container = document.querySelector("ytd-watch-flexy ytd-player #container");
container.insertBefore(canvas, container.firstChild);
updatefog();
} catch (e) {
requestAnimationFrame(waitForContainer);
}
}
waitForContainer();
}
else {
canvas.remove();
cancelAnimationFrame(fograf);
}
})();