-
Notifications
You must be signed in to change notification settings - Fork 8
/
reveal-nav-bar-javascript.js
42 lines (31 loc) · 1.15 KB
/
reveal-nav-bar-javascript.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
let guide = document.querySelector('#guide');
let container = document.querySelector('#contentContainer');
let button = document.querySelector('#guide-button');
//Hides nav bar when loaded
guide.removeAttribute("guide-persistent-and-visible");
guide.removeAttribute("opened");
guide.setAttribute("mini-guide-visible", "");
container.removeAttribute("opened");
//Allow transitions to play
button.addEventListener("click", () => guide.setAttribute("reveal-nav-bar", ""));
//Re-arrange thumbnails
document.addEventListener('afterscriptexecute', () => window.dispatchEvent(new Event('resize')));
//When URL changes, hide nav bar
new MutationObserver(mutations => {
if (container.hasAttribute("opened")) button.click();
}).observe(document.querySelector('title'), { childList: true });
(function() {
'use strict';
const header = document.querySelector('div#header.ytd-app');
if (header) {
function updateHeaderDisplay() {
if (window.location.pathname === '/') {
header.style.display = 'none';
} else {
header.style.display = 'flex';
}
requestAnimationFrame(updateHeaderDisplay);
}
updateHeaderDisplay();
}
})();