-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhide.js
40 lines (35 loc) · 1.16 KB
/
hide.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
/*
** A content script that listens for messages, then hides suggested videos on YouTube.
*/
chrome.runtime.onMessage.addListener(messageReceived);
function messageReceived(message, sender, sendResponse) {
if (message.txt == "cleanSidebar") {
cleanSidebar();
} else if (message.txt == "cleanRecc") {
cleanRecc();
}
}
// Clears side bar videos
function cleanSidebar() {
const sideBar = document.getElementById("related");
if (sideBar != null) {
sideBar.style.display = "none";
}
}
/* Clears recommended videos on the front page and subscription page
** Videos on Home, Trending, Subs, and Library have tagname "YTD-BROWSE".
** Home videos have page-subtype.value "home"
** Trending videos have null page-Subtype
** Subscription videos have page-subtype.value "subscriptions"
** Library videos have null page-subtype
*/
function cleanRecc() {
const videoPage = document.getElementsByClassName("ytd-page-manager");
for (var vid of videoPage) {
var subtype = vid.attributes.getNamedItem("page-subtype");
var tag = vid.tagName;
if (tag === "YTD-BROWSE" && (subtype == null || subtype.value === "home")) {
vid.style.display = "none";
}
}
}