|
1 | 1 | // ==UserScript== |
2 | 2 | // @name YouTube™ Classic 📺 — (Remove rounded design + Return YouTube dislikes) |
3 | | -// @version 2025.10.18.3 |
| 3 | +// @version 2025.10.18.4 |
4 | 4 | // @author Adam Lui, Magma_Craft, Anarios, JRWR, Fuim & hoothin |
5 | 5 | // @namespace https://github.com/adamlui |
6 | 6 | // @description Reverts YouTube to its classic design (before all the rounded corners & hidden dislikes) + redirects YouTube Shorts |
|
299 | 299 | if (options?.updatedKey == 'disableShorts') |
300 | 300 | shortsObserver[config.disableShorts ? 'observe' : 'disconnect'](document.body, obsConfig) |
301 | 301 | else if (options?.updatedKey == 'adBlock') |
302 | | - adObserver[config.adBlock ? 'observe' : 'disconnect'](document.documentElement, obsConfig) |
| 302 | + homeObserver[config.adBlock ? 'observe' : 'disconnect'](document.documentElement, obsConfig) |
303 | 303 | if (options?.updatedKey.includes('Block')) |
304 | 304 | window.configStyle.textContent = Object.entries(domSelectors) |
305 | 305 | .map(([key, selectors]) => !config[`${key}Block`] ? '' |
|
2228 | 2228 | if (config.disableShorts) getLoadedElem('body').then(() => shortsObserver.observe(document.body, obsConfig)) |
2229 | 2229 |
|
2230 | 2230 | // Remove homepage ads/rich sections |
2231 | | - const adObserver = new MutationObserver(() => { |
| 2231 | + const homeObserver = new MutationObserver(() => { |
2232 | 2232 | if (location.pathname != locationPath) { // nav'd to diff page, re-observe |
2233 | | - locationPath = location.pathname ; adObserver.disconnect() |
2234 | | - getLoadedElem('html').then(() => adObserver.observe(document.documentElement, obsConfig)) |
2235 | | - } else if (locationPath == '/') // remove ads |
2236 | | - document.querySelector('ytd-ad-slot-renderer')?.closest('[rendered-from-rich-grid]')?.remove() |
| 2233 | + locationPath = location.pathname ; homeObserver.disconnect() |
| 2234 | + getLoadedElem('html').then(() => homeObserver.observe(document.documentElement, obsConfig)) |
| 2235 | + } else if (locationPath == '/') { // remove homepage shelves (for no gaps) + ads |
| 2236 | + const adSlot = document.querySelector('ytd-ad-slot-renderer') |
| 2237 | + const richSection = document.querySelector( |
| 2238 | + `ytd-rich-section-renderer${ !config.shortsBlock ? ':not(:has(a[href*="/shorts/"]))' : '' }${ |
| 2239 | + !config.playablesBlock ? ':not(:has(a[href*="/playables/"]))' : '' }` |
| 2240 | + ) |
| 2241 | + adSlot?.closest('[rendered-from-rich-grid]')?.remove() ; richSection?.remove() |
| 2242 | + } |
2237 | 2243 | }) |
2238 | 2244 | if (config.shortsBlock || config.playablesBlock || config.adBlock) |
2239 | | - getLoadedElem('html').then(() => adObserver.observe(document.documentElement, obsConfig)) |
| 2245 | + getLoadedElem('html').then(() => homeObserver.observe(document.documentElement, obsConfig)) |
2240 | 2246 |
|
2241 | 2247 | // Block stuff |
2242 | 2248 | document.head.append(window.configStyle ??= document.createElement('style')) |
|
0 commit comments