-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathytspeed.js
42 lines (38 loc) · 1.21 KB
/
ytspeed.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
function initDash() {
var dash = document.createElement("div");
dash.style.position = "fixed";
dash.style.right = "0";
dash.style.bottom = "0";
dash.style.zIndex = "4999";
var x = document.createElement("div");
x.textContent = "❌";
x.addEventListener("click", function () {
dash.remove();
});
dash.appendChild(x);
var range = document.createElement("input");
range.type = "range";
range.min = 0;
range.max = 1;
range.step = 0.1;
range.value = 0.7;
range.addEventListener("input", function () {
var video = document.getElementsByTagName("video")[0];
video.style.filter = "brightness(" + this.value + ")";
});
dash.appendChild(range);
var speed = document.createElement("div");
for (var i of [1, 2, 3, 5, 10]) {
var button = document.createElement("button");
button.value = i;
button.textContent = "x" + i;
speed.appendChild(button);
}
speed.addEventListener("click", function (e) {
var video = document.getElementsByTagName("video")[0];
video.playbackRate = parseInt(e.target.value);
});
dash.appendChild(speed);
document.body.appendChild(dash);
}
initDash();