Moves the New releases section to the top of the page
Size
3.2 KB
Version
1.0.1
Created
Jan 24, 2026
Updated
10 days ago
1// ==UserScript==
2// @name YouTube Music - New Releases First
3// @description Moves the New releases section to the top of the page
4// @version 1.0.1
5// @match https://*.music.youtube.com/*
6// @icon https://music.youtube.com/img/favicon_32.png
7// ==/UserScript==
8(function() {
9 'use strict';
10
11 function moveNewReleasesToTop() {
12 console.log('Looking for New releases section...');
13
14 // Find the New releases section
15 const allSections = document.querySelectorAll('ytmusic-carousel-shelf-renderer.style-scope.ytmusic-section-list-renderer');
16 let newReleasesSection = null;
17
18 for (const section of allSections) {
19 const titleLink = section.querySelector('a.yt-simple-endpoint[href="new_releases/albums"]');
20 if (titleLink && titleLink.textContent.trim() === 'New releases') {
21 newReleasesSection = section;
22 console.log('Found New releases section');
23 break;
24 }
25 }
26
27 if (!newReleasesSection) {
28 console.log('New releases section not found yet');
29 return;
30 }
31
32 // Find the parent container that holds all sections
33 const sectionList = document.querySelector('ytmusic-section-list-renderer.style-scope.ytmusic-browse-response');
34 if (!sectionList) {
35 console.log('Section list container not found');
36 return;
37 }
38
39 // Find the first section (to insert before it)
40 const firstSection = sectionList.querySelector('ytmusic-carousel-shelf-renderer.style-scope.ytmusic-section-list-renderer');
41
42 if (firstSection && firstSection !== newReleasesSection) {
43 console.log('Moving New releases to the top...');
44 // Move the New releases section before the first section
45 firstSection.parentNode.insertBefore(newReleasesSection, firstSection);
46 console.log('New releases section moved to top successfully');
47 } else {
48 console.log('New releases is already at the top');
49 }
50 }
51
52 function init() {
53 console.log('YouTube Music - New Releases First extension started');
54
55 // Try to move immediately
56 setTimeout(moveNewReleasesToTop, 2000);
57
58 // Watch for DOM changes (YouTube Music is a single-page app)
59 const observer = new MutationObserver(function(mutations) {
60 moveNewReleasesToTop();
61 });
62
63 // Start observing when the main content area is available
64 const waitForContent = setInterval(() => {
65 const contentArea = document.querySelector('ytmusic-section-list-renderer.style-scope.ytmusic-browse-response');
66 if (contentArea) {
67 clearInterval(waitForContent);
68 observer.observe(contentArea, {
69 childList: true,
70 subtree: true
71 });
72 console.log('Started observing for changes');
73 }
74 }, 1000);
75 }
76
77 // Start when page is ready
78 if (document.readyState === 'loading') {
79 document.addEventListener('DOMContentLoaded', init);
80 } else {
81 init();
82 }
83})();