// ==UserScript== // @name YouTube Play All // @description Adds the Play-All-Button to the videos section of a YouTube-Channel // @version 2024-03-25.2 // @author Robert Wesner (https://robert.wesner.io) // @license MIT // @namespace http://robert.wesner.io/ // @match https://*.youtube.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; document.head.insertAdjacentHTML('beforeend', ``); setInterval(() => { if (!window.location.pathname.endsWith('/videos') || document.querySelector('.play-all-button')) { return; } fetch('.') .then(_ => _.text()) .then(html => { const i = html.indexOf(' div'), document.querySelector('ytm-compact-video-renderer a'), ] : [ // desktop view document.querySelector('ytd-feed-filter-chip-bar-renderer iron-selector#chips'), document.querySelector('div#primary a#thumbnail'), ]; if (!latestVideo) { // content was not loaded yet, no latest video found -> retry next cycle return; } latestVideo = latestVideo.attributes.href.value; parent.insertAdjacentHTML( 'beforeend', // Check if popular videos are displayed parent.querySelector(':nth-child(2).selected, :nth-child(2).iron-selected') // list=UULP has the all videos sorted by popular ? `Play Popular` // list=UU adds shorts into the playlist, list=UULF has videos without shorts : `Play All`, ); }).catch(); }, 1000); })();