-
Notifications
You must be signed in to change notification settings - Fork 1
/
YoutubeClock.user.js
33 lines (28 loc) · 976 Bytes
/
YoutubeClock.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
// ==UserScript==
// @name YoutubeClock
// @namespace https://oxodao.fr/
// @version 1
// @description Add a simple clock to the youtube bar so that you don't need to close fullscreen to see it.
// @author Nathan <Oxodao> JANCZEWSKI
// @match https://www.youtube.com/watch?v=*
// @grant none
// ==/UserScript==
(function() {
'use strict';
let bar = document.getElementsByClassName("ytp-right-controls")[0];
let clock = document.createElement("span");
clock.classList.add("ytp-time-display");
function clockTime() {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
if (h < 10) h = "0" + h;
if (m < 10) m = "0" + m;
if (s < 10) s = "0" + s;
clock.innerText = h + ":" + m + ":" + s;
setTimeout(clockTime, 500);
}
clockTime();
bar.insertBefore(clock, bar.childNodes[0]);
})();