|
1 | 1 | // ==UserScript== |
2 | 2 | // @name YouTube™ Classic 📺 — (Remove rounded design + Return YouTube dislikes) |
3 | | -// @version 2026.1.17.26 |
| 3 | +// @version 2026.1.17.27 |
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 |
|
1807 | 1807 | return result |
1808 | 1808 | } |
1809 | 1809 |
|
1810 | | - let mutationObserver = new Object() |
| 1810 | + const mutationObserver = new Object() |
1811 | 1811 |
|
1812 | 1812 | if (isShorts() && !mutationObserver.exists) { |
1813 | 1813 | cLog('initializing mutation observer') |
|
1871 | 1871 |
|
1872 | 1872 | function createRateBar(likes, dislikes) { |
1873 | 1873 | if (isMobile) { return } |
1874 | | - let rateBar = document.getElementById('return-youtube-dislike-bar-container') |
1875 | | - const widthPx = |
1876 | | - getBtns().children[0].clientWidth + |
1877 | | - getBtns().children[1].clientWidth + |
1878 | | - 8 |
1879 | | - const widthPercent = likes + dislikes > 0 ? (likes / (likes + dislikes)) * 100 : 50 |
1880 | | - let likePercentage = parseFloat(widthPercent.toFixed(1)) |
1881 | | - const dislikePercentage = (100 - likePercentage).toLocaleString() |
1882 | | - likePercentage = likePercentage.toLocaleString() |
| 1874 | + const rateBar = document.getElementById('return-youtube-dislike-bar-container'), |
| 1875 | + widthPx = getBtns().children[0].clientWidth + getBtns().children[1].clientWidth +8, |
| 1876 | + widthPercent = likes + dislikes > 0 ? (likes / (likes + dislikes)) *100 : 50, |
| 1877 | + likePercent = parseFloat(widthPercent.toFixed(1)).toLocaleString(), |
| 1878 | + dislikePercent = (100 - likePercent).toLocaleString() |
1883 | 1879 | let tooltipInnerHTML |
1884 | 1880 | switch (extConfig.tooltipPercentageMode) { |
1885 | 1881 | case 'dash_like': |
1886 | | - tooltipInnerHTML = `${likes.toLocaleString()} / ${dislikes.toLocaleString()} - ${likePercentage}%` |
| 1882 | + tooltipInnerHTML = `${likes.toLocaleString()} / ${dislikes.toLocaleString()} - ${likePercent}%` |
1887 | 1883 | break |
1888 | 1884 | case 'dash_dislike': |
1889 | | - tooltipInnerHTML = `${likes.toLocaleString()} / ${dislikes.toLocaleString()} - ${dislikePercentage}%` |
| 1885 | + tooltipInnerHTML = `${likes.toLocaleString()} / ${dislikes.toLocaleString()} - ${dislikePercent}%` |
1890 | 1886 | break |
1891 | 1887 | case 'both': |
1892 | | - tooltipInnerHTML = `${likePercentage}% / ${dislikePercentage}%` |
| 1888 | + tooltipInnerHTML = `${likePercent}% / ${dislikePercent}%` |
1893 | 1889 | break |
1894 | 1890 | case 'only_like': |
1895 | | - tooltipInnerHTML = `${likePercentage}%` |
| 1891 | + tooltipInnerHTML = `${likePercent}%` |
1896 | 1892 | break |
1897 | 1893 | case 'only_dislike': |
1898 | | - tooltipInnerHTML = `${dislikePercentage}%` |
| 1894 | + tooltipInnerHTML = `${dislikePercent}%` |
1899 | 1895 | break |
1900 | 1896 | default: |
1901 | 1897 | tooltipInnerHTML = `${likes.toLocaleString()} / ${dislikes.toLocaleString()}` |
1902 | 1898 | } |
1903 | 1899 | if (!rateBar && !isMobile) { |
1904 | 1900 | let colorDislikeStyle = '' |
1905 | | - if (extConfig.coloredBar) { |
| 1901 | + if (extConfig.coloredBar) |
1906 | 1902 | colorDislikeStyle = '; background-color: ' + getColorFromTheme(false) |
1907 | | - } |
1908 | 1903 | document.getElementById('menu-container').insertAdjacentHTML( |
1909 | 1904 | 'beforeend', |
1910 | 1905 | ` |
|
1965 | 1960 | if (extConfig.coloredThumbs) { |
1966 | 1961 | if (isShorts()) { |
1967 | 1962 | // for shorts, leave deactived buttons in default color |
1968 | | - let shortLikeButton = getLikeBtn().querySelector( |
1969 | | - 'tp-yt-paper-button#button' |
1970 | | - ) |
1971 | | - let shortDislikeButton = getDislikeBtn().querySelector( |
1972 | | - 'tp-yt-paper-button#button' |
1973 | | - ) |
1974 | | - if (shortLikeButton.getAttribute('aria-pressed') == 'true') { |
1975 | | - shortLikeButton.style.color = getColorFromTheme(true) |
1976 | | - } |
1977 | | - if (shortDislikeButton.getAttribute('aria-pressed') == 'true') { |
1978 | | - shortDislikeButton.style.color = getColorFromTheme(false) |
1979 | | - } |
1980 | | - mutationObserver.observer.observe( |
1981 | | - shortLikeButton, |
1982 | | - mutationObserver.options |
1983 | | - ) |
1984 | | - mutationObserver.observer.observe( |
1985 | | - shortDislikeButton, |
1986 | | - mutationObserver.options |
1987 | | - ) |
| 1963 | + const shortLikeBtn = getLikeBtn().querySelector('tp-yt-paper-button#button'), |
| 1964 | + shortDislikeBtn = getDislikeBtn().querySelector('tp-yt-paper-button#button') |
| 1965 | + if (shortLikeBtn.getAttribute('aria-pressed') == 'true') |
| 1966 | + shortLikeBtn.style.color = getColorFromTheme(true) |
| 1967 | + if (shortDislikeBtn.getAttribute('aria-pressed') == 'true') |
| 1968 | + shortDislikeBtn.style.color = getColorFromTheme(false) |
| 1969 | + mutationObserver.observer.observe(shortLikeBtn, mutationObserver.options) |
| 1970 | + mutationObserver.observer.observe(shortDislikeBtn, mutationObserver.options) |
1988 | 1971 | } else { |
1989 | 1972 | getLikeBtn().style.color = getColorFromTheme(true) |
1990 | 1973 | getDislikeBtn().style.color = getColorFromTheme(false) |
|
2160 | 2143 | setEventListeners() |
2161 | 2144 | })() |
2162 | 2145 | if (isMobile) { |
2163 | | - let originalPush = history.pushState |
| 2146 | + const originalPush = history.pushState |
2164 | 2147 | history.pushState = function(...args) { |
2165 | 2148 | unsafeWindow.returnDislikeButtonlistenersSet = false |
2166 | 2149 | setEventListeners() |
|
0 commit comments