-
Notifications
You must be signed in to change notification settings - Fork 0
/
noShorts.js
40 lines (35 loc) · 1.22 KB
/
noShorts.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
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
let cleanedSidebar = false;
var observer = new MutationObserver(function(mutations, observer) {
if (!cleanedSidebar) {clearSidebar();}
clearRichSelectionRow();
clearVideos();
});
// define what element should be observed by the observer
// and what types of mutations trigger the callback
observer.observe(document, {
subtree: true,
attributes: true
});
// Will remve the shorts button from the youtube sidebar
function clearSidebar() {
const shortsSidebar = document.querySelector('a[title="Shorts"]');
if (shortsSidebar !== null) {
shortsSidebar.parentElement.remove();
cleanedSidebar = true
}
}
// Will remove any rich selection row, including Shorts, News
function clearRichSelectionRow() {
const richSelectionRows = document.querySelectorAll('ytd-rich-section-renderer');
[...richSelectionRows].forEach(function(row) {
row.remove();
})
}
// Will remove any uploaded shorts on your subscription page
function clearVideos() {
const shortVideos = document.querySelectorAll('span[aria-label="Shorts"]');
[...shortVideos].forEach(function(video) {
video.closest('ytd-rich-item-renderer.ytd-rich-grid-row').remove();
})
}