This repository has been archived by the owner on May 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
youtube-better-frontpage.user.js
69 lines (58 loc) · 2.21 KB
/
youtube-better-frontpage.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
// ==UserScript==
// @name YouTube Better Front Page
// @namespace https://github.com/Poorchop/userscripts
// @description Hides the nasty bits on the default YouTube front page, leaving only the important bits
// @include http*://www.youtube.com/*
// @version 1.1
// @grant none
// ==/UserScript==
/* jshint browser: true, esnext: true */
let observer;
function addCustomCSS() {
let betterCSS = "#body-container { background: #fff !important; }" +
"#yt-masthead-container { background: #fff !important; border-bottom: none !important; }" +
".yt-masthead-logo-container { float: none !important; margin-top: 250px !important;" +
"position: unset !important; text-align: center !important; width: unset !important; }" +
"#yt-masthead-signin, #yt-masthead-user { float: none !important; margin-top: unset !important;" +
"margin-left: unset !important; position: absolute !important; right: 10px !important; top: 10px !important; }" +
"#masthead-search { margin: auto !important; }" +
"#appbar-guide-button-container { display: none !important; }" +
"#page-container { display: none !important; }" +
"#footer-container {display: none !important; }" +
"#masthead-appbar { display: none; }" +
"#masthead-user-button { margin: 0px 0px 0px 10px }"; // YouTube Center button
let betterStyle = document.createElement("style");
betterStyle.type = "text/css";
betterStyle.id = "better-css";
betterStyle.appendChild(document.createTextNode(betterCSS));
document.head.appendChild(betterStyle);
}
function applyStyles() {
if (window.location.pathname === "/") {
addCustomCSS();
} else {
let styles = document.getElementById("better-css");
if (styles) {
styles.parentElement.removeChild(styles);
}
}
}
function bodyChange(mutations) {
for (let mutation of mutations) {
for (let element of mutation.addedNodes) {
if (element.id === "progress") {
applyStyles();
}
}
}
}
function init() {
/* don't do anything inside iframes */
if (window.self !== window.top) {
return;
}
observer = new MutationObserver(bodyChange);
observer.observe(document.body, { childList: true });
applyStyles();
}
init();