|
1 | 1 | // ==UserScript== |
2 | 2 | // @name YouTube™ Classic 📺 — (Remove rounded design + Return YouTube dislikes) |
3 | | -// @version 2026.1.17.17 |
| 3 | +// @version 2026.1.17.18 |
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 |
|
369 | 369 | static observer = new MutationObserver(this.onNewScript) |
370 | 370 | static _config = {} |
371 | 371 | static isObject(item) { |
372 | | - return (item && typeof item === 'object' && !Array.isArray(item)) |
| 372 | + return (item && typeof item == 'object' && !Array.isArray(item)) |
373 | 373 | } |
374 | 374 | static mergeDeep(target, ...sources) { |
375 | 375 | if (!sources.length) return target |
|
1742 | 1742 | let mobileDislikes = 0 |
1743 | 1743 |
|
1744 | 1744 | function cLog(text, subtext = '') { |
1745 | | - subtext = subtext.trim() === '' ? '' : `(${subtext})` |
| 1745 | + subtext = subtext.trim() == '' ? '' : `(${subtext})` |
1746 | 1746 | console.log(`[Return YouTube Dislikes] ${text} ${subtext}`) |
1747 | 1747 | } |
1748 | 1748 |
|
|
1780 | 1780 | document.querySelector('.slim-video-action-bar-actions') |
1781 | 1781 | ) |
1782 | 1782 | } |
1783 | | - if (document.getElementById('menu-container')?.offsetParent === null) { |
| 1783 | + if (document.getElementById('menu-container')?.offsetParent == null) { |
1784 | 1784 | return ( |
1785 | 1785 | document.querySelector('ytd-menu-renderer.ytd-watch-metadata > div') ?? |
1786 | 1786 | document.querySelector('ytd-menu-renderer.ytd-video-primary-info-renderer > div') |
|
1793 | 1793 | } |
1794 | 1794 |
|
1795 | 1795 | function getLikeButton() { |
1796 | | - return getButtons().children[0].tagName === |
| 1796 | + return getButtons().children[0].tagName == |
1797 | 1797 | 'YTD-SEGMENTED-LIKE-DISLIKE-BUTTON-RENDERER' |
1798 | 1798 | ? getButtons().children[0].children[0] |
1799 | 1799 | : getButtons().children[0] |
|
1808 | 1808 | } |
1809 | 1809 |
|
1810 | 1810 | function getDislikeButton() { |
1811 | | - return getButtons().children[0].tagName === |
| 1811 | + return getButtons().children[0].tagName == |
1812 | 1812 | 'YTD-SEGMENTED-LIKE-DISLIKE-BUTTON-RENDERER' |
1813 | 1813 | ? getButtons().children[0].children[1] |
1814 | 1814 | : getButtons().children[1] |
|
1819 | 1819 | getDislikeButton().querySelector('#text') ?? |
1820 | 1820 | getDislikeButton().getElementsByTagName('yt-formatted-string')[0] ?? |
1821 | 1821 | getDislikeButton().querySelector('span[role="text"]') |
1822 | | - if (result === null) { |
| 1822 | + if (result == null) { |
1823 | 1823 | let textSpan = document.createElement('span') |
1824 | 1824 | textSpan.id = 'text' |
1825 | 1825 | textSpan.style.marginLeft = '2px' |
|
1832 | 1832 |
|
1833 | 1833 | let mutationObserver = new Object() |
1834 | 1834 |
|
1835 | | - if (isShorts() && mutationObserver.exists !== true) { |
| 1835 | + if (isShorts() && mutationObserver.exists != true) { |
1836 | 1836 | cLog('initializing mutation observer') |
1837 | 1837 | mutationObserver.options = { |
1838 | 1838 | childList: false, |
|
1843 | 1843 | mutationObserver.observer = new MutationObserver(function(mutationList) { |
1844 | 1844 | mutationList.forEach((mutation) => { |
1845 | 1845 | if ( |
1846 | | - mutation.type === 'attributes' && |
1847 | | - mutation.target.nodeName === 'TP-YT-PAPER-BUTTON' && |
1848 | | - mutation.target.id === 'button' |
| 1846 | + mutation.type == 'attributes' && |
| 1847 | + mutation.target.nodeName == 'TP-YT-PAPER-BUTTON' && |
| 1848 | + mutation.target.id == 'button' |
1849 | 1849 | ) { |
1850 | 1850 | cLog('Short thumb button status changed') |
1851 | | - if (mutation.target.getAttribute('aria-pressed') === 'true') { |
| 1851 | + if (mutation.target.getAttribute('aria-pressed') == 'true') { |
1852 | 1852 | mutation.target.style.color = |
1853 | | - mutation.target.parentElement.parentElement.id === 'like-button' |
| 1853 | + mutation.target.parentElement.parentElement.id == 'like-button' |
1854 | 1854 | ? getColorFromTheme(true) |
1855 | 1855 | : getColorFromTheme(false) |
1856 | 1856 | } else { |
|
1984 | 1984 | likesvalue = likes |
1985 | 1985 | dislikesvalue = dislikes |
1986 | 1986 | setDislikes(numberFormat(dislikes)) |
1987 | | - if (extConfig.numberDisplayReformatLikes === true) { |
| 1987 | + if (extConfig.numberDisplayReformatLikes == true) { |
1988 | 1988 | const nativeLikes = getLikeCountFromButton() |
1989 | 1989 | if (nativeLikes != null) setLikes(numberFormat(nativeLikes)) |
1990 | 1990 | } |
1991 | 1991 | createRateBar(likes, dislikes) |
1992 | | - if (extConfig.coloredThumbs === true) { |
| 1992 | + if (extConfig.coloredThumbs == true) { |
1993 | 1993 | if (isShorts()) { |
1994 | 1994 | // for shorts, leave deactived buttons in default color |
1995 | 1995 | let shortLikeButton = getLikeButton().querySelector( |
|
1998 | 1998 | let shortDislikeButton = getDislikeButton().querySelector( |
1999 | 1999 | 'tp-yt-paper-button#button' |
2000 | 2000 | ) |
2001 | | - if (shortLikeButton.getAttribute('aria-pressed') === 'true') { |
| 2001 | + if (shortLikeButton.getAttribute('aria-pressed') == 'true') { |
2002 | 2002 | shortLikeButton.style.color = getColorFromTheme(true) |
2003 | 2003 | } |
2004 | | - if (shortDislikeButton.getAttribute('aria-pressed') === 'true') { |
| 2004 | + if (shortDislikeButton.getAttribute('aria-pressed') == 'true') { |
2005 | 2005 | shortDislikeButton.style.color = getColorFromTheme(false) |
2006 | 2006 | } |
2007 | 2007 | mutationObserver.observer.observe( |
|
2040 | 2040 | createRateBar(likesvalue, dislikesvalue) |
2041 | 2041 | previousState = 1 |
2042 | 2042 | } |
2043 | | - if (extConfig.numberDisplayReformatLikes === true) { |
| 2043 | + if (extConfig.numberDisplayReformatLikes == true) { |
2044 | 2044 | const nativeLikes = getLikeCountFromButton() |
2045 | 2045 | if (nativeLikes != null) setLikes(numberFormat(nativeLikes)) |
2046 | 2046 | } |
|
2065 | 2065 | setDislikes(numberFormat(dislikesvalue)) |
2066 | 2066 | createRateBar(likesvalue, dislikesvalue) |
2067 | 2067 | previousState = 2 |
2068 | | - if (extConfig.numberDisplayReformatLikes === true) { |
| 2068 | + if (extConfig.numberDisplayReformatLikes == true) { |
2069 | 2069 | const nativeLikes = getLikeCountFromButton() |
2070 | 2070 | if (nativeLikes != null) setLikes(numberFormat(nativeLikes)) |
2071 | 2071 | } |
|
2088 | 2088 | function isVideoLoaded() { |
2089 | 2089 | if (isMobile) { return document.getElementById('player').getAttribute('loading') == 'false' } |
2090 | 2090 | const videoId = getVideoId() |
2091 | | - return ( document.querySelector(`ytd-watch-flexy[video-id='${videoId}']`) !== null ) |
| 2091 | + return ( document.querySelector(`ytd-watch-flexy[video-id='${videoId}']`) != null ) |
2092 | 2092 | } |
2093 | 2093 |
|
2094 | 2094 | function roundDown(num) { |
|
2101 | 2101 |
|
2102 | 2102 | function numberFormat(numberState) { |
2103 | 2103 | let numberDisplay |
2104 | | - if (extConfig.numberDisplayRoundDown === false) { numberDisplay = numberState |
| 2104 | + if (extConfig.numberDisplayRoundDown == false) { numberDisplay = numberState |
2105 | 2105 | } else { numberDisplay = roundDown(numberState) } |
2106 | 2106 | return getNumberFormatter(extConfig.numberDisplayFormat).format(numberDisplay) |
2107 | 2107 | } |
|
2149 | 2149 | let colorString |
2150 | 2150 | switch (extConfig.colorTheme) { |
2151 | 2151 | case 'accessible': |
2152 | | - if (voteIsLike === true) { |
| 2152 | + if (voteIsLike == true) { |
2153 | 2153 | colorString = 'dodgerblue' |
2154 | 2154 | } else { colorString = 'gold' } |
2155 | 2155 | break |
2156 | 2156 | case 'neon': |
2157 | | - if (voteIsLike === true) { |
| 2157 | + if (voteIsLike == true) { |
2158 | 2158 | colorString = 'aqua' |
2159 | 2159 | } else { colorString = 'magenta' } |
2160 | 2160 | break |
2161 | 2161 | case 'classic': |
2162 | 2162 | default: |
2163 | | - if (voteIsLike === true) { |
| 2163 | + if (voteIsLike == true) { |
2164 | 2164 | colorString = 'lime' |
2165 | 2165 | } else { colorString = 'red' } |
2166 | 2166 | } |
|
2202 | 2202 | return originalPush.apply(history, args) |
2203 | 2203 | } |
2204 | 2204 | setInterval(() => { |
2205 | | - if (getDislikeButton().querySelector('.button-renderer-text') === null) { |
| 2205 | + if (getDislikeButton().querySelector('.button-renderer-text') == null) { |
2206 | 2206 | getDislikeTextContainer().innerText = mobileDislikes |
2207 | 2207 | } else { getDislikeButton().querySelector('.button-renderer-text').innerText = mobileDislikes } |
2208 | 2208 | }, 1000) |
|
0 commit comments