Skip to content

Instantly share code, notes, and snippets.

@Far-Se
Last active July 20, 2022 05:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Far-Se/3f4df8a0b3baa823409cf32194154f8b to your computer and use it in GitHub Desktop.
Save Far-Se/3f4df8a0b3baa823409cf32194154f8b to your computer and use it in GitHub Desktop.
Youtube new Sidebar, cleaner and playlists separated from Youtube generated lists.
// ==UserScript==
// @name Youtube New Sidebar
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Youtube new Sidebar, cleaner and playlists separated from Youtube generated lists.
// @author Your Grandma
// @match https://www.youtube.com/*
// @icon https://t1.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=https://youtube.com
// @grant none
// ==/UserScript==
let intVV = setInterval(()=>{
if (document.querySelector('#endpoint[title="Show more"]')) {
document.querySelector('#endpoint[title="Show more"]').dispatchEvent(new Event('click',{
bubbles: true
}));
clearInterval(intVV);
///
////New Sidebar
///
setTimeout(()=>{
let sidebar = []
document.querySelector('h3 + #items').setAttribute('style', `height:0;overflow:hidden;position:relative;`);
document.querySelector('#newMenu') && (document.querySelector('#newMenu').outerHTML = '');
//#sections >ytd-guide-section-renderer:first-child #items a[role="tablist"]
document.querySelectorAll('#sections >ytd-guide-section-renderer:first-child #items a[role="tablist"]').forEach((e,i)=>{
sidebar.push({text: e.querySelector('.title').innerText,el: e.closest('ytd-guide-entry-renderer')});
});
document.querySelector('h3 + #items').insertAdjacentHTML('afterend', '<div id="newMenu"></div>');
let playlists = sidebar.filter(e=>~e.text.indexOf('-'));
sidebar = sidebar.filter(e=>!e.text.match(/(Show |library|your|downloads|-)/i));
playlists.sort((b,a)=>Date.parse(a.text) - Date.parse(b.text));
let addMenu = (arr)=>{arr.forEach(e=>{document.querySelector('#newMenu').insertAdjacentElement('beforeend', e.el);});};
addMenu(sidebar);
document.querySelector('#newMenu').insertAdjacentHTML('beforeend', `<div style="border: 1px solid #373737;margin: 10px 0px;"></div>`);
document.querySelector('#newMenu').insertAdjacentHTML('beforeend', `<h3 style=" font-family: Roboto, Arial, sans-serif; --app-drawer-width: 240px; --app-drawer-content-container-background-color: var(--yt-spec-general-background-a); visibility: visible; --yt-endpoint-color: var(--yt-spec-text-primary); --paper-item-min-height: 40px; color: var(--yt-spec-text-secondary); display: block; padding: 8px 24px; font-size: var(--ytd-tab-system_-_font-size); font-weight: var(--ytd-tab-system_-_font-weight); letter-spacing: var(--ytd-tab-system_-_letter-spacing); text-transform: var(--ytd-tab-system_-_text-transform);">Playlists</h3>`);
addMenu(playlists);
document.querySelectorAll('.ytd-app #sections ytd-guide-section-renderer:not(:first-child)').forEach(e=>e.style.display = "none");
document.querySelector('#guide-inner-content div#footer').style.display = "none"; // Legal stuff
}
, 100);
}
}
, 100);
@Far-Se
Copy link
Author

Far-Se commented Jan 8, 2022

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment