|
1 | 1 | // ==UserScript== |
2 | 2 | // @name YouTube™ Classic 📺 — (Remove rounded design + Return YouTube dislikes) |
3 | | -// @version 2026.1.17.50 |
| 3 | +// @version 2026.1.17.51 |
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 |
|
370 | 370 | class YTP { |
371 | 371 | static observer = new MutationObserver(this.onNewScript) |
372 | 372 | static _config = {} |
373 | | - static isObject(item) { |
374 | | - return (item && typeof item == 'object' && !Array.isArray(item)) |
375 | | - } |
| 373 | + static isObject(item) { return (item && typeof item == 'object' && !Array.isArray(item)) } |
376 | 374 | static mergeDeep(target, ...sources) { |
377 | 375 | if (!sources.length) return target |
378 | 376 | const source = sources.shift() |
379 | | - if (this.isObject(target) && this.isObject(source)) { |
380 | | - for (const key in source) { |
381 | | - if (this.isObject(source[key])) { |
382 | | - if (!target[key]) Object.assign(target, { [key]: {} }) |
383 | | - this.mergeDeep(target[key], source[key]) |
384 | | - } else { |
385 | | - Object.assign(target, { [key]: source[key] }) |
386 | | - } |
387 | | - } |
388 | | - } |
| 377 | + if (this.isObject(target) && this.isObject(source)) for (const key in source) |
| 378 | + if (this.isObject(source[key])) { |
| 379 | + if (!target[key]) Object.assign(target, { [key]: {} }) |
| 380 | + this.mergeDeep(target[key], source[key]) |
| 381 | + } else Object.assign(target, { [key]: source[key] }) |
389 | 382 | return this.mergeDeep(target, ...sources) |
390 | 383 | } |
391 | 384 | static onNewScript(mutations) { if (mutations.some(mut => mut.addedNodes.length)) YTP.bruteforce() } |
392 | 385 | static start() { this.observer.observe(document, {childList: true, subtree: true}) } |
393 | 386 | static stop() { this.observer.disconnect() } |
394 | 387 | static bruteforce() { |
395 | | - if (!unsafeWindow.yt) return |
396 | | - if (!unsafeWindow.yt.config_) return |
| 388 | + if (!unsafeWindow.yt?.config_) return |
397 | 389 | this.mergeDeep(unsafeWindow.yt.config_, this._config) |
398 | 390 | } |
399 | 391 | static setCfg(name, value) { this._config[name] = value } |
|
0 commit comments