Skip to content

Commit b802d56

Browse files
committed
Replaced homeObserver node removals w/ CSS (but leaves gaps in 1st grid) (fixes adamlui/youtube-classic#150) ↞ [auto-sync from https://github.com/adamlui/youtube-classic]
1 parent 831cdde commit b802d56

1 file changed

Lines changed: 9 additions & 24 deletions

File tree

youtube-classic/youtube-classic.user.js

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name YouTube™ Classic 📺 — (Remove rounded design + Return YouTube dislikes)
3-
// @version 2026.3.6.1
3+
// @version 2026.4.14
44
// @author Adam Lui, Magma_Craft, Fuim & hoothin
55
// @namespace https://github.com/adamlui
66
// @description Reverts YouTube to its classic design (before all the rounded corners & hidden dislikes) + redirects YouTube Shorts
@@ -104,17 +104,22 @@
104104
settings.load(Object.keys(settings.controls))
105105

106106
app.selectors = { site: {
107-
ad: { masthead: 'div#masthead-ad' }, // https://imgur.com/a/kOWzh3O
107+
ad: {
108+
masthead: 'div#masthead-ad', // https://imgur.com/a/kOWzh3O
109+
thumbnail: 'ytd-rich-item-renderer:has(ytd-ad-slot-renderer)'
110+
},
108111
ai: {
109112
askBtn: 'button:has(path[d*=M480-80q0-83])',
110113
askSection: 'yt-video-description-youchat-section-view-model',
111114
summary: 'div#header[class*=expandable-metadata]:has(path[d*=M480-80q0-83])'
112115
},
113-
playables: { shelf: 'ytd-rich-section-renderer:has(a[href*="/playables/"])' },
116+
playables: {
117+
shelf: 'ytd-rich-section-renderer:has(a[href*="/playables/"])'
118+
},
114119
shorts: {
115120
navEntry: 'a#endpoint[title=Shorts]',
116121
shelf: {
117-
homepage: 'div.ytd-rich-shelf-renderer:has(a[href*="/shorts/"])', // https://imgur.com/a/LMdO92M
122+
homepage: 'ytd-rich-section-renderer:has(a[href*="/shorts/"])', // https://imgur.com/a/LMdO92M
118123
results: 'grid-shelf-view-model:has(a[href*="/shorts/"])' // https://imgur.com/a/vVzoEfH
119124
}
120125
}
@@ -1040,9 +1045,6 @@
10401045

10411046
// CONFIG hacks
10421047

1043-
let locationPath = location.pathname // to track nav
1044-
const obsConfig = { childList: true, subtree: true }
1045-
10461048
// Redirect Shorts to classic player
10471049
if (app.config.disableShorts) checkShortsToRedir()
10481050
function checkShortsToRedir() {
@@ -1051,23 +1053,6 @@
10511053
checkShortsToRedir.id = requestAnimationFrame(checkShortsToRedir)
10521054
}
10531055

1054-
// Remove homepage ads/rich sections
1055-
const homeObserver = new MutationObserver(() => {
1056-
if (location.pathname != locationPath) { // nav'd to diff page, re-observe
1057-
locationPath = location.pathname ; homeObserver.disconnect()
1058-
dom.get.loadedElem('html').then(() => homeObserver.observe(document.documentElement, obsConfig))
1059-
} else if (locationPath == '/') { // remove regenerating homepage stuff
1060-
if (app.config.adBlock) // remove ads
1061-
document.querySelector('ytd-ad-slot-renderer')?.closest('[rendered-from-rich-grid]')?.remove()
1062-
if (app.config.shortsBlock || app.config.playablesBlock) // remove shelves
1063-
document.querySelector(`ytd-rich-section-renderer${
1064-
!app.config.shortsBlock ? ':not(:has(a[href*="/shorts/"]))' : '' }${
1065-
!app.config.playablesBlock ? ':not(:has(a[href*="/playables/"]))' : '' }`
1066-
)?.remove()
1067-
}
1068-
})
1069-
dom.get.loadedElem('html').then(() => homeObserver.observe(document.documentElement, obsConfig))
1070-
10711056
// Set/update subscribe button pos
10721057
dom.get.loadedElem('ytd-subscribe-button-renderer button').then(subBtn => {
10731058
requestAnimationFrame(updateSubBtnPos)

0 commit comments

Comments
 (0)