Skip to content

Commit 4e03578

Browse files
committed
Made cheap homeObserver persistent
1 parent 0a7487a commit 4e03578

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

youtube-classic/youtube-classic.user.js

Lines changed: 11 additions & 12 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 2025.10.19.1
3+
// @version 2025.10.19.2
44
// @author Adam Lui, Magma_Craft, Anarios, JRWR, 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
@@ -297,8 +297,6 @@
297297
}
298298

299299
function syncConfigToUI(options) {
300-
if (options?.updatedKey == 'adBlock')
301-
homeObserver[config.adBlock ? 'observe' : 'disconnect'](document.documentElement, obsConfig)
302300
if (options?.updatedKey.includes('Block'))
303301
window.configStyle.textContent = Object.entries(domSelectors)
304302
.map(([key, selectors]) => !config[`${key}Block`] ? ''
@@ -2228,17 +2226,18 @@
22282226
if (location.pathname != locationPath) { // nav'd to diff page, re-observe
22292227
locationPath = location.pathname ; homeObserver.disconnect()
22302228
getLoadedElem('html').then(() => homeObserver.observe(document.documentElement, obsConfig))
2231-
} else if (locationPath == '/') { // remove homepage shelves (for no gaps) + ads
2232-
const adSlot = document.querySelector('ytd-ad-slot-renderer')
2233-
const richSection = document.querySelector(
2234-
`ytd-rich-section-renderer${ !config.shortsBlock ? ':not(:has(a[href*="/shorts/"]))' : '' }${
2235-
!config.playablesBlock ? ':not(:has(a[href*="/playables/"]))' : '' }`
2236-
)
2237-
adSlot?.closest('[rendered-from-rich-grid]')?.remove() ; richSection?.remove()
2229+
} else if (locationPath == '/') { // remove regenerating homepage stuff
2230+
if (config.adBlock) // remove ads
2231+
document.querySelector('ytd-ad-slot-renderer')?.closest('[rendered-from-rich-grid]')?.remove()
2232+
if (config.shortsBlock || config.playablesBlock) { // remove shelves
2233+
document.querySelector(
2234+
`ytd-rich-section-renderer${ !config.shortsBlock ? ':not(:has(a[href*="/shorts/"]))' : '' }${
2235+
!config.playablesBlock ? ':not(:has(a[href*="/playables/"]))' : '' }`
2236+
)?.remove()
2237+
}
22382238
}
22392239
})
2240-
if (config.shortsBlock || config.playablesBlock || config.adBlock)
2241-
getLoadedElem('html').then(() => homeObserver.observe(document.documentElement, obsConfig))
2240+
getLoadedElem('html').then(() => homeObserver.observe(document.documentElement, obsConfig))
22422241

22432242
// Block stuff
22442243
document.head.append(window.configStyle ??= document.createElement('style'))

0 commit comments

Comments
 (0)